-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.py
75 lines (71 loc) · 1.97 KB
/
controller.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from api import *
import threading, os, sys, time
class myThread (threading.Thread):
def __init__(self, botId):
threading.Thread.__init__(self)
self.botId = botId
def run(self):
os.system("python3 code.py "+str(self.botId))
level=0
numbots=1
while level == 0:
level = int(input("Please enter level(1/2/3/4/5/6): "))
if not (0 < level < 7):
level = 0
continue
else:
# TODO: Guided tour of the level
if level == 1 or level == 2:
numbots = 1
elif level == 3 or level == 5:
numbots = 2
elif level == 4 or level == 6:
numbots = max(min(8, int(input("Number of bots in play(max 8): "))),2)
else:
level = 0
continue
print("Starting Level ", level," with ", numbots, "bot(s)")
set_new_map(level, numbots)
time.sleep(2)
if level == 1:
os.system("python3 code.py 0")
print("The final score is: " + str(get_score()))
elif level == 2:
os.system("python3 code.py 0")
print("The final score is: " + str(get_score()))
elif level == 3:
threads = []
for i in range(2):
thread = myThread(i)
threads.append(thread)
thread.start()
for t in threads:
t.join()
print("The final score is: "+str(get_score()))
elif level == 4:
threads = []
for i in range(get_numbots()):
thread = myThread(i)
threads.append(thread)
thread.start()
for t in threads:
t.join()
print("The final score is: "+str(get_score()))
elif level == 5:
threads = []
for i in range(2):
thread = myThread(i)
threads.append(thread)
thread.start()
for t in threads:
t.join()
print("The final score is: "+str(get_score()))
elif level == 6:
threads = []
for i in range(get_numbots()):
thread = myThread(i)
threads.append(thread)
thread.start()
for t in threads:
t.join()
print("The final score is: "+str(get_score()))