-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunner.py
More file actions
41 lines (30 loc) · 1.12 KB
/
Runner.py
File metadata and controls
41 lines (30 loc) · 1.12 KB
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
import sys
from model import *
from MyStrategy import MyStrategy
from RemoteProcessClient import RemoteProcessClient
class Runner:
def __init__(self):
if sys.argv.__len__() == 4:
self.remote_process_client = RemoteProcessClient(
sys.argv[1], int(sys.argv[2]))
self.token = sys.argv[3]
else:
self.remote_process_client = RemoteProcessClient(
"127.0.0.1", 31001)
self.token = "0000000000000000"
def run(self):
strategy = MyStrategy()
self.remote_process_client.write_token(self.token)
rules = self.remote_process_client.read_rules()
while True:
game = self.remote_process_client.read_game()
if game is None:
break
actions = {}
for robot in game.robots:
if robot.is_teammate:
action = Action()
strategy.act(robot, rules, game, action)
actions[robot.id] = action
self.remote_process_client.write(actions, strategy.custom_rendering())
Runner().run()