-
-
Save Debilski/0f83566968acd4e900da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FoodEatingPlayer(AbstractPlayer): | |
def set_initial(self): | |
self.adjacency = AdjacencyList(self.current_uni.reachable([self.initial_pos])) | |
self.next_food = None | |
def goto_pos(self, pos): | |
return self.adjacency.a_star(self.current_pos, pos)[-1] | |
def get_move(self): | |
# check, if food is still present | |
if (self.next_food is None | |
or self.next_food not in self.enemy_food): | |
self.next_food = self.rnd.choice(self.enemy_food) | |
try: | |
next_pos = self.goto_pos(self.next_food) | |
move = diff_pos(self.current_pos, next_pos) | |
return move | |
except NoPathException: | |
return datamodel.stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment