Skip to content
This repository was archived by the owner on Jan 17, 2021. It is now read-only.

Commit 6de4402

Browse files
committed
added max rounds to game analysis
1 parent 9ddf30d commit 6de4402

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

python-visualizer/game_analysis.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
import config
1212

13+
14+
MAX_ROUND = 25
15+
16+
1317
def append_to_csv(file_name: str, elements):
1418
with open(file_name, 'a+', newline='') as write:
1519
csv_writer = writer(write)
@@ -61,15 +65,15 @@ async def play():
6165
append_to_csv(board_size_file_name, [state["width"], state["height"]])
6266
rounds += 1
6367

64-
if not state["running"]:
68+
if not state["running"] or rounds == MAX_ROUND:
6569
break
6670

6771
deadline = datetime.strptime(state["deadline"], '%Y-%m-%dT%H:%M:%SZ')
6872
available_millis = (deadline - transform_to_server_time(datetime.now())) / timedelta(milliseconds=1)
6973
print(f"\tavailable milliseconds: %d" % available_millis)
7074
append_to_csv(time_file_name, [int(available_millis)])
7175

72-
action_json = json.dumps({"action": "change_nothing"})
76+
action_json = json.dumps({"action": "turn_right"})
7377
await websocket.send(action_json)
7478

7579

0 commit comments

Comments
 (0)