Fix TypeError on game end
@@ -121,7 +121,12 @@ async def _play_game_ai(client, player_id, ai, realtime, step_time_limit, game_t
state = await client.observation()
# check game result every time we get the observation
if client._game_result:
+ try:
await ai.on_end(client._game_result[player_id])
+ except TypeError as error:
+ # print(f"caught type error {error}")
+ # print(f"return {client._game_result[player_id]}")
+ return client._game_result[player_id]
return client._game_result[player_id]
gs = GameState(state.observation)
logger.debug(f"Score: {gs.score.summary}")
@@ -202,7 +207,12 @@ async def _play_game_ai(client, player_id, ai, realtime, step_time_limit, game_t
logger.exception(f"AI step threw an error") # DO NOT EDIT!
logger.error(f"Error: {e}")
logger.error(f"Resigning due to previous error")
+ try:
await ai.on_end(Result.Defeat)
+ except TypeError as error:
+ # print(f"caught type error {error}")
+ # print(f"return {Result.Defeat}")
+ return Result.Defeat
return Result.Defeat
logger.debug(f"Running AI step: done")
