Example #1
0
    def generate_move(self, tiles: List[Tile], board_state: BoardState) -> Result[Tile]:
        """
        Send the board state and tile options to the client player via TCP, and receives the action
        taken by the player.

        :param tiles:           The set of tile options for the first move
        :param board_state:     The state of the current board
        :return:                A result containing the tile that will be placed for the given player
        """        
        state_pats = board_state.to_state_pats()
        message = ["take-turn", [state_pats, tile_to_index(tiles[0]), tile_to_index(tiles[1])]]
        return self._handle_communication(message, self._handle_intermediate_received)
Example #2
0
    def generate_first_move(
        self, tiles: List[Tile], board_state: BoardState
    ) -> Result[Tuple[BoardPosition, Tile, PortID]]:
        """
        Send the board state and tile options to the client player via TCP, and receives the initial action
        taken by the player.

        :param tiles:           The set of tile options for the first move
        :param board_state:     The state of the current board
        :return:                A result containing a tuple containing the board position, tile, and port ID
                                for the player's initial move
        """
        state_pats = board_state.to_state_pats()
        message = ["initial", [state_pats, tile_to_index(tiles[0]), tile_to_index(tiles[1]), tile_to_index(tiles[2])]]
        return self._handle_communication(message, self._handle_initial_received)