Package Search

Interface GameSearch

  • All Known Implementing Classes:
    DomineeringSearch

    public interface GameSearch
    Interface for defining game search functionality.
    Since:
    2023-12-01
    Version:
    1.0
    Author:
    Laamiri Ouail & Hajar Sadik
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      byte getNextPlayer()
      Get the next player to make a move.
      byte getNumberOfPosibleMove​(byte player)
      Get the number of possible moves for the specified player.
      byte getNumbreOfMoveByPlayer​(byte player)
      Get the number of moves made by the specified player.
      java.util.List<Board> getValideStates​(byte player)
      Get a list of valid game states for the specified player.
      java.util.List<int[]> getValidMoves​(java.lang.String[][] state, byte player)
      Get a list of valid moves for the specified player based on the current state.
      java.util.List<Move> getValidMovesi​(byte player)
      Get a list of valid moves for the specified player.
      int heuristic​(int[] move)
      Calculate the heuristic value for a move.
      void makeHelpMove​(int x, int y, byte player)
      Make a helper move on the game board.
      void makeMove​(int y, int x, byte player)
      Make a move on the game board.
      int[] maxValue​(java.lang.String[][] state, int depth, int alpha, int beta, int[] move)
      Get the maximum value for a state in a minimax search.
      int[] minmax​(java.lang.String[][] state, int depth, boolean myMove, int[] alpha, int[] beta)
      Perform a minimax search on the game state.
      int[] minValue​(java.lang.String[][] state, int depth, int alpha, int beta, int[] move)
      Get the minimum value for a state in a minimax search.
      byte playerWin()
      Check if a player has won the game.
      boolean playHelpMove​(int x, int y)
      Play a move on the game board for a helper move.
      boolean playMove​(int x, int y)
      Play a move on the game board.
    • Method Detail

      • getNumberOfPosibleMove

        byte getNumberOfPosibleMove​(byte player)
        Get the number of possible moves for the specified player.
        Parameters:
        player - The player for whom to get the number of possible moves.
        Returns:
        The number of possible moves for the player.
      • getNumbreOfMoveByPlayer

        byte getNumbreOfMoveByPlayer​(byte player)
        Get the number of moves made by the specified player.
        Parameters:
        player - The player for whom to get the number of moves.
        Returns:
        The number of moves made by the player.
      • getNextPlayer

        byte getNextPlayer()
        Get the next player to make a move.
        Returns:
        The next player to make a move.
      • getValidMovesi

        java.util.List<Move> getValidMovesi​(byte player)
        Get a list of valid moves for the specified player.
        Parameters:
        player - The player for whom to get valid moves.
        Returns:
        A list of valid moves for the player.
      • getValidMoves

        java.util.List<int[]> getValidMoves​(java.lang.String[][] state,
                                            byte player)
        Get a list of valid moves for the specified player based on the current state.
        Parameters:
        state - The current state of the game.
        player - The player for whom to get valid moves.
        Returns:
        A list of valid moves for the player.
      • getValideStates

        java.util.List<Board> getValideStates​(byte player)
        Get a list of valid game states for the specified player.
        Parameters:
        player - The player for whom to get valid game states.
        Returns:
        A list of valid game states for the player.
      • playerWin

        byte playerWin()
        Check if a player has won the game.
        Returns:
        The winning player or 0 if no player has won.
      • makeMove

        void makeMove​(int y,
                      int x,
                      byte player)
        Make a move on the game board.
        Parameters:
        y - The y-coordinate of the move.
        x - The x-coordinate of the move.
        player - The player making the move.
      • playMove

        boolean playMove​(int x,
                         int y)
        Play a move on the game board.
        Parameters:
        x - The x-coordinate of the move.
        y - The y-coordinate of the move.
        Returns:
        True if the move was played successfully, false otherwise.
      • maxValue

        int[] maxValue​(java.lang.String[][] state,
                       int depth,
                       int alpha,
                       int beta,
                       int[] move)
        Get the maximum value for a state in a minimax search.
        Parameters:
        state - The current state of the game.
        depth - The depth of the search.
        alpha - The alpha value for pruning.
        beta - The beta value for pruning.
        move - The best move found so far.
        Returns:
        An array containing the best move and its value.
      • minValue

        int[] minValue​(java.lang.String[][] state,
                       int depth,
                       int alpha,
                       int beta,
                       int[] move)
        Get the minimum value for a state in a minimax search.
        Parameters:
        state - The current state of the game.
        depth - The depth of the search.
        alpha - The alpha value for pruning.
        beta - The beta value for pruning.
        move - The best move found so far.
        Returns:
        An array containing the best move and its value.
      • minmax

        int[] minmax​(java.lang.String[][] state,
                     int depth,
                     boolean myMove,
                     int[] alpha,
                     int[] beta)
        Perform a minimax search on the game state.
        Parameters:
        state - The current state of the game.
        depth - The depth of the search.
        myMove - True if it's the current player's move, false otherwise.
        alpha - The alpha value for pruning.
        beta - The beta value for pruning.
        Returns:
        An array containing the best move and its value.
      • playHelpMove

        boolean playHelpMove​(int x,
                             int y)
        Play a move on the game board for a helper move.
        Parameters:
        x - The x-coordinate of the helper move.
        y - The y-coordinate of the helper move.
        Returns:
        True if the helper move was played successfully, false otherwise.
      • makeHelpMove

        void makeHelpMove​(int x,
                          int y,
                          byte player)
        Make a helper move on the game board.
        Parameters:
        x - The x-coordinate of the helper move.
        y - The y-coordinate of the helper move.
        player - The player making the helper move.
      • heuristic

        int heuristic​(int[] move)
        Calculate the heuristic value for a move.
        Parameters:
        move - An array containing the move coordinates and value.
        Returns:
        The heuristic value for the move.