if got Key Error in move function create a new snake and calculate next best move
This commit is contained in:
@@ -96,6 +96,10 @@ class Server:
|
||||
|
||||
# move is called when your Battlesnake game is running game
|
||||
def _move(self, game_state:dict) -> dict:
|
||||
try:
|
||||
next_move = self.running_snake[game_state["game"]["id"]].choose_move(game_state)
|
||||
except KeyError:
|
||||
self.running_snake[game_state["game"]["id"]] = SnakeBuilder.build(self.snake_type)
|
||||
next_move = self.running_snake[game_state["game"]["id"]].choose_move(game_state)
|
||||
|
||||
if self.store_game_state:
|
||||
|
||||
Reference in New Issue
Block a user