save direction to kill the snake use the correct kill direction in overwrite_eat_the_other_snake can end in a draw when both heads are by the food
This commit is contained in:
@@ -122,10 +122,11 @@ class TemplateSnake:
|
||||
for snake in self.other_snakes:
|
||||
for direction, location in self.safe_positions.items():
|
||||
if len(self.safe_positions) > 1:
|
||||
#TODO: Avoid Draw when heads are by the food
|
||||
if snake["length"] < self.my_snake["length"] and location in [{"x": v["x"], "y": v["y"]} for k, v in self.get_possible_moves(snake["head"]).items()]:
|
||||
self.eat_the_snake_overwrite = True
|
||||
return direction
|
||||
#TODO: Check if snake on the way to the bood here and only remove this pos
|
||||
self.kill_the_snake = direction
|
||||
#TODO: Check if snake on the way to the food here and only remove this pos
|
||||
elif location in [{"x": v["x"], "y": v["y"]} for k, v in self.get_possible_moves(snake["head"]).items()]:
|
||||
remove.append(direction)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user