fix error where my snake got not found in avoid_get_eaten_by_other_snakes
This commit is contained in:
@@ -127,11 +127,11 @@ class TemplateSnake:
|
|||||||
for direction, location in safe_positions.items():
|
for direction, location in safe_positions.items():
|
||||||
if len(safe_positions) > 1:
|
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()]
|
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.eat_the_snake_overwrite = True
|
||||||
self.kill_the_snake = direction
|
self.kill_the_snake = direction
|
||||||
#TODO: Testing - Check if snake on the way to the food here and only remove this pos
|
#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)
|
remove.append(direction)
|
||||||
elif location in self.other_snake_posible_moves:
|
elif location in self.other_snake_posible_moves:
|
||||||
no_way_out[direction] = location
|
no_way_out[direction] = location
|
||||||
|
|||||||
Reference in New Issue
Block a user