Exemple #1
0
    def visit(self, game_board: GameBoard):
        for goal in game_board.get_goals():
            for step in game_board.get_cell_steps(goal['point']).steps_data:
                for path_scorer in self._path_scorers:

                    if path_scorer.can_score_path(step, goal['type'], self._you['id']):
                        path_follower = PathFollower(game_board,
                                                     goal['type'],
                                                     step.point_type,
                                                     step.point_id,
                                                     step.distance,
                                                     self._you,
                                                     path_scorer)

                        path = path_follower.score_path(goal['point'])
                        if path['distance'] == 0:
                            print(f"Unexpected path distance of zero for {goal} and {path}")
                        else:
                            game_board.add_path(path_follower.score_path(goal['point']))
Exemple #2
0
    def visit(self, game_board: GameBoard):
        cell_area = self.CellArea(game_board)

        neighbour_points = RelativePoint.get_neighbour_points(
            (self._you_snake_head['x'], self._you_snake_head['y']))
        point_id = 0
        for neighbour_point in neighbour_points:
            cell_count = len(cell_area.collect(neighbour_point))
            score = game_board.get_total_cells() - cell_count + 1000
            path = {
                'goal_type': None,
                'point_type': PointType.AVAILABLE_AREA,
                'point_id': 'area-' + str(point_id),
                'distance': cell_count,
                'points': [neighbour_point],
                'scores': [score],
                'final_score': score
            }

            game_board.add_path(path)

            point_id = point_id + 1