fix a error where self.safe_positions[0] can't be accest

This commit is contained in:
2024-04-17 08:19:32 +02:00
parent 93b2c8ba99
commit 0fe4e6ac83
+3 -2
View File
@@ -128,9 +128,10 @@ class BetterMasterSnake(TemplateSnake):
self.find_safe_positions()
if self.eat_the_snake_overwrite:
if len(self.safe_positions) > 1:
self.add_calculations({"function": "eat_the_snake_overwrite", "my_head": self.my_head, "move": move, "safe_positions": self.safe_positions[0]})
first_key = list(self.safe_positions.keys())[0]
self.add_calculations({"function": "eat_the_snake_overwrite", "my_head": self.my_head, "move": move, "safe_positions": self.safe_positions, "selected_move": self.safe_positions[first_key]})
self.add_to_history({"turn": game_data["turn"], "data": self.calculations})
return self.safe_positions[0]
return self.safe_positions[first_key]
self.add_calculations({"function": "eat_the_snake_overwrite", "my_head": self.my_head, "move": move, "safe_positions": self.safe_positions})
self.add_to_history({"turn": game_data["turn"], "data": self.calculations})