From ef4dca447fc778a1c182e11d4e84e7b96ea5dc29 Mon Sep 17 00:00:00 2001 From: Daniel Dolezal Date: Thu, 18 Apr 2024 23:56:49 +0200 Subject: [PATCH] fix error where my snake got not found in avoid_get_eaten_by_other_snakes --- snakes/TemplateSnake.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snakes/TemplateSnake.py b/snakes/TemplateSnake.py index fbe489b..ecde468 100644 --- a/snakes/TemplateSnake.py +++ b/snakes/TemplateSnake.py @@ -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