fix error where my snake got not found in avoid_get_eaten_by_other_snakes

This commit is contained in:
2024-04-18 23:56:49 +02:00
parent db3a353090
commit ef4dca447f
+2 -2
View File
@@ -127,11 +127,11 @@ class TemplateSnake:
for direction, location in safe_positions.items():
if len(safe_positions) > 1:
self.other_snake_posible_moves = [{"x": v["x"], "y": v["y"]} for k, v in self.get_possible_moves(snake["head"]).items()]
if snake["length"] < self.my_snake["length"] and location in self.other_snake_posible_moves:
if snake["length"] < self.game_board.get_my_snake()["length"] and location in self.other_snake_posible_moves:
self.eat_the_snake_overwrite = True
self.kill_the_snake = direction
#TODO: Testing - Check if snake on the way to the food here and only remove this pos
elif location in self.other_snake_posible_moves and location in [{"x": food["x"], "y": food["y"]} for food in self.food_positions]:
elif location in self.other_snake_posible_moves and location in [{"x": food["x"], "y": food["y"]} for food in self.game_board.get_food()]:
remove.append(direction)
elif location in self.other_snake_posible_moves:
no_way_out[direction] = location