src/quagen/ai/biased.py
def choose_move(self):
        """
        Asks the AI to choose a next move given the current state of the
        game and board.

        Returns:
            (tuple) Board coordinates in the form of (x, y)
        """
        available_spots = self.get_movable_spots()
        if not available_spots:
            raise Exception("No available moves for AI to choose from.")

        # The potential spots we are going to project and ultimately choose from
        candidate_spots = []
        choosen_spot = None

        if self._game.turn_completed == 0:
            # At the start of the game, we will choose a random spot towards
            # the middle of the board
            center_x = int(self._game.settings["dimension_x"] / 2)
            pick_x = random.randint(
                center_x - BiasedAI.OPENING_RADIUS, center_x + BiasedAI.OPENING_RADIUS
            )

            center_y = int(self._game.settings["dimension_y"] / 2)
            pick_y = random.randint(
                center_y - BiasedAI.OPENING_RADIUS, center_y + BiasedAI.OPENING_RADIUS
            )

            choosen_spot = (pick_x, pick_y)
        else:
            # Let's look at spots which are around opponents' recent moves.
            # Countering an opponent's move typically has a high projection
            # depending on the board state and stage of the game.
            lookback_count = BiasedAI.LOOKBACK_CANDIDATE_COUNT[self._strength]
            lookback_turns = BiasedAI.LOOKBACK_TURNS
            lookback_spots = self._get_lookback_candidates(
                available_spots, lookback_count, lookback_turns
            )

            candidate_spots += lookback_spots
            available_spots = [
                spot for spot in available_spots if spot not in candidate_spots
            ]

            # All the available spots should be in (x, y) order. We'll divide
            # up the board into chunks and randomly pick candidates
            # equally from each chunk. This lets the AI project spots
            # distributed all over the board without having to look at
            # every spot on the board.
            distributed_count = BiasedAI.DISTRIBUTED_CANDIDATE_COUNT[self._strength]
            distrubted_spots = self._get_distributed_candidates(
                available_spots, distributed_count
            )

            candidate_spots += distrubted_spots
            available_spots = [
                spot for spot in available_spots if spot not in candidate_spots
            ]

            # Pick the best of the candidates according to the AI's criteria
            choosen_spot = self._evaluate_candidates(candidate_spots)

        return choosen_spot

        Asks the AI to choose a next move given the current state of the
        game and board.

        Returns:
            (tuple) Board coordinates in the form of (x, y)
        
Asks the AI to choose a next move given the current state of the
game and board.
Asks the AI to choose a next move given the current state of the game and board .
def choose_move(self):
        available_spots = self.get_movable_spots()
        if not available_spots:
            raise Exception("No available moves for AI to choose from.")
        candidate_spots = []
        choosen_spot = None
        if self._game.turn_completed == 0:
            center_x = int(self._game.settings["dimension_x"] / 2)
            pick_x = random.randint(
                center_x - BiasedAI.OPENING_RADIUS, center_x + BiasedAI.OPENING_RADIUS
            )
            center_y = int(self._game.settings["dimension_y"] / 2)
            pick_y = random.randint(
                center_y - BiasedAI.OPENING_RADIUS, center_y + BiasedAI.OPENING_RADIUS
            )
            choosen_spot = (pick_x, pick_y)
        else:
            lookback_count = BiasedAI.LOOKBACK_CANDIDATE_COUNT[self._strength]
            lookback_turns = BiasedAI.LOOKBACK_TURNS
            lookback_spots = self._get_lookback_candidates(
                available_spots, lookback_count, lookback_turns
            )
            candidate_spots += lookback_spots
            available_spots = [
                spot for spot in available_spots if spot not in candidate_spots
            ]
            distributed_count = BiasedAI.DISTRIBUTED_CANDIDATE_COUNT[self._strength]
            distrubted_spots = self._get_distributed_candidates(
                available_spots, distributed_count
            )
            candidate_spots += distrubted_spots
            available_spots = [
                spot for spot in available_spots if spot not in candidate_spots
            ]
            choosen_spot = self._evaluate_candidates(candidate_spots)
        return choosen_spot
def choose_move ( self ) : available_spots = self . get_movable_spots ( ) if not available_spots : raise Exception ( "No available moves for AI to choose from." ) candidate_spots = [ ] choosen_spot = None if self . _game . turn_completed == 0 : center_x = int ( self . _game . settings [ "dimension_x" ] / 2 ) pick_x = random . randint ( center_x - BiasedAI . OPENING_RADIUS , center_x + BiasedAI . OPENING_RADIUS ) center_y = int ( self . _game . settings [ "dimension_y" ] / 2 ) pick_y = random . randint ( center_y - BiasedAI . OPENING_RADIUS , center_y + BiasedAI . OPENING_RADIUS ) choosen_spot = ( pick_x , pick_y ) else : lookback_count = BiasedAI . LOOKBACK_CANDIDATE_COUNT [ self . _strength ] lookback_turns = BiasedAI . LOOKBACK_TURNS lookback_spots = self . _get_lookback_candidates ( available_spots , lookback_count , lookback_turns ) candidate_spots += lookback_spots available_spots = [ spot for spot in available_spots if spot not in candidate_spots ] distributed_count = BiasedAI . DISTRIBUTED_CANDIDATE_COUNT [ self . _strength ] distrubted_spots = self . _get_distributed_candidates ( available_spots , distributed_count ) candidate_spots += distrubted_spots available_spots = [ spot for spot in available_spots if spot not in candidate_spots ] choosen_spot = self . _evaluate_candidates ( candidate_spots ) return choosen_spot
Asks the AI to choose a next move given the current state of the
game and board.
Asks the AI to choose a next move given the current state of the game and board .
"""
        Asks the AI to choose a next move given the current state of the
        game and board.

        Returns:
            (tuple) Board coordinates in the form of (x, y)
        """ # The potential spots we are going to project and ultimately choose from # At the start of the game, we will choose a random spot towards # the middle of the board # Let's look at spots which are around opponents' recent moves. # Countering an opponent's move typically has a high projection # depending on the board state and stage of the game. # All the available spots should be in (x, y) order. We'll divide # up the board into chunks and randomly pick candidates # equally from each chunk. This lets the AI project spots # distributed all over the board without having to look at # every spot on the board. # Pick the best of the candidates according to the AI's criteria
(tuple) Board coordinates in the form of (x, y)
( tuple ) Board coordinates in the form of ( x y )
self