forked from IsaiahPressman/Kaggle_Lux_AI_2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (45 loc) · 1.51 KB
/
main.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
from contextlib import redirect_stdout
import io
# Silence "Loading environment football failed: No module named 'gfootball'" message
with redirect_stdout(io.StringIO()):
import kaggle_environments
from typing import Dict
from lux_ai.rl_agent.rl_agent import agent
# from lux_ai.handcrafted_agents.needs_name_v0 import agent
if __name__ == "__main__":
def read_input():
"""
Reads input from stdin
"""
try:
return input()
except EOFError as eof:
raise SystemExit(eof)
step = 0
class Observation(Dict[str, any]):
def __init__(self, player=0):
self.player = player
# self.updates = []
# self.step = 0
observation = Observation()
observation["updates"] = []
observation["step"] = 0
observation["remainingOverageTime"] = 60.
player_id = 0
while True:
inputs = read_input()
observation["updates"].append(inputs)
if step == 0:
player_id = int(observation["updates"][0])
observation.player = player_id
"""
# fixes bug where updates array is shared, but the first update is agent dependent actually
observation["updates"][0] = f"{observation.player}"
"""
if inputs == "D_DONE":
actions = agent(observation, None)
observation["updates"] = []
step += 1
observation["step"] = step
print(",".join(actions))
print("D_FINISH")