Exemple #1
0
 def get_info(self) -> GameData:
     info = GameData()
     info.snake_length = len(self.snake)
     info.head_x = self.snake[0][0]
     info.head_y = self.snake[0][1]
     info.direction = {(0, 1): "south", (0, -1): "north", (1, 0): "east", (-1, 0): "west"}[self.direction]
     info.walldistance_n = info.head_y
     info.walldistance_s = self.field.height - info.head_y - 1
     info.walldistance_w = info.head_x
     info.walldistance_e = self.field.width - info.head_x - 1
     info.food_x = self.food[0]
     info.food_y = self.food[1]
     info.field = self.field
     info.body = self.snake  # copy.deepcopy(self.snake)
     info.game_over = self.is_game_over()
     return info