remove not used function is_food_nearby
This commit is contained in:
@@ -5,7 +5,6 @@ class BetterMasterSnake(TemplateSnake):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.name = "BetterMasterSnake"
|
||||
self.disabled_check_if_food_is_near_by = True
|
||||
# Definiere die möglichen Bewegungsrichtungen
|
||||
self.min_safe_area = 2
|
||||
|
||||
@@ -128,7 +127,7 @@ class BetterMasterSnake(TemplateSnake):
|
||||
|
||||
self.find_safe_positions()
|
||||
if self.eat_the_snake_overwrite:
|
||||
move = self.overwrite_eat_the_other_snake(move, game_data["turn"])
|
||||
return self.overwrite_eat_the_other_snake(move, game_data["turn"])
|
||||
|
||||
if self.game_type == "constrictor":
|
||||
move = self.selected_move_constrictor()
|
||||
@@ -155,13 +154,12 @@ class BetterMasterSnake(TemplateSnake):
|
||||
self.add_calculations({"function": "find_direction", "my_head": self.my_head, "move": move})
|
||||
return move
|
||||
|
||||
def selected_move_standard(self):
|
||||
def selected_move_standard(self, move=None):
|
||||
# Finde den besten Weg zur Nahrung
|
||||
if self.is_food_nearby() or self.disabled_check_if_food_is_near_by:
|
||||
path_to_food = self.find_path_to_food()
|
||||
if path_to_food:
|
||||
move = self.move_towards(path_to_food[0])
|
||||
self.add_calculations({"function": "move_towards", "my_head": self.my_head, "path_to_food": path_to_food, "move": move})
|
||||
path_to_food = self.find_path_to_food()
|
||||
if path_to_food:
|
||||
move = self.move_towards(path_to_food[0])
|
||||
self.add_calculations({"function": "move_towards", "my_head": self.my_head, "path_to_food": path_to_food, "move": move})
|
||||
|
||||
if not move:
|
||||
move = self.move_close_to_body()
|
||||
@@ -172,15 +170,6 @@ class BetterMasterSnake(TemplateSnake):
|
||||
self.add_calculations({"function": "ensure_escape_route", "my_head": self.my_head, "move": move, "safe_positions": self.safe_positions})
|
||||
return move
|
||||
|
||||
def is_food_nearby(self):
|
||||
for food in self.food_positions:
|
||||
if abs(self.my_head['x'] - food['x']) <= 1 and abs(self.my_head['y'] - food['y']) <= 1:
|
||||
self.add_calculations({"function": "is_food_nearby", "my_head": self.my_head, "food": food, "return": True})
|
||||
return True
|
||||
|
||||
self.add_calculations({"function": "is_food_nearby", "my_head": self.my_head, "food_positions": self.food_positions, "return": False})
|
||||
return False
|
||||
|
||||
def find_path_to_food(self):
|
||||
# Exclude own snake's body from obstacles
|
||||
obstacles = set((part['x'], part['y']) for part in self.my_body)
|
||||
|
||||
Reference in New Issue
Block a user