Package Search
Class DomineeringSearch
- java.lang.Object
 - 
- Search.DomineeringSearch
 
 
- 
- All Implemented Interfaces:
 GameSearch
public class DomineeringSearch extends java.lang.Object implements GameSearch
The DomineeringSearch class implements the GameSearch interface for the Domineering game. It utilizes the Singleton pattern to ensure a single instance of the class.- Since:
 - 2023-12-01
 - Version:
 - 1.0
 - Author:
 - Laamiri Ouail & Hajar Sadik
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description private static DomineeringSearchdomineeringSearchInstanceSingleton instance 
- 
Constructor Summary
Constructors Modifier Constructor Description privateDomineeringSearch()Private constructor for Singleton pattern. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DomineeringSearchgetInstance()Get the instance of DomineeringSearch using the Singleton pattern.bytegetNextPlayer()Get the next player to make a move.bytegetNumberOfPosibleMove(byte player)Get the number of possible moves for the specified player.bytegetNumbreOfMoveByPlayer(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.intheuristic(int[] move)Calculate the heuristic value for a move.voidmakeHelpMove(int x, int y, byte player)Make a helper move on the game board.voidmakeMove(int x, int y, 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.byteplayerWin()Check if a player has won the game.booleanplayHelpMove(int x, int y)Play a move on the game board for a helper move.booleanplayMove(int x, int y)Play a move on the game board. 
 - 
 
- 
- 
Field Detail
- 
domineeringSearchInstance
private static DomineeringSearch domineeringSearchInstance
Singleton instance 
 - 
 
- 
Method Detail
- 
getInstance
public static DomineeringSearch getInstance()
Get the instance of DomineeringSearch using the Singleton pattern.- Returns:
 - The DomineeringSearch instance.
 
 
- 
getNumbreOfMoveByPlayer
public byte getNumbreOfMoveByPlayer(byte player)
Get the number of moves made by the specified player.- Specified by:
 getNumbreOfMoveByPlayerin interfaceGameSearch- Parameters:
 player- The player for whom to get the number of moves.- Returns:
 - The number of moves made by the player.
 
 
- 
getValidMovesi
public java.util.List<Move> getValidMovesi(byte player)
Get a list of valid moves for the specified player.- Specified by:
 getValidMovesiin interfaceGameSearch- Parameters:
 player- The player for whom to get valid moves.- Returns:
 - A list of valid moves for the player.
 
 
- 
getValidMoves
public 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.- Specified by:
 getValidMovesin interfaceGameSearch- 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
public java.util.List<Board> getValideStates(byte player)
Get a list of valid game states for the specified player.- Specified by:
 getValideStatesin interfaceGameSearch- Parameters:
 player- The player for whom to get valid game states.- Returns:
 - A list of valid game states for the player.
 
 
- 
getNextPlayer
public byte getNextPlayer()
Get the next player to make a move.- Specified by:
 getNextPlayerin interfaceGameSearch- Returns:
 - The next player to make a move.
 
 
- 
getNumberOfPosibleMove
public byte getNumberOfPosibleMove(byte player)
Get the number of possible moves for the specified player.- Specified by:
 getNumberOfPosibleMovein interfaceGameSearch- Parameters:
 player- The player for whom to get the number of possible moves.- Returns:
 - The number of possible moves for the player.
 
 
- 
playerWin
public byte playerWin()
Check if a player has won the game.- Specified by:
 playerWinin interfaceGameSearch- Returns:
 - The winning player or 0 if no player has won.
 
 
- 
makeMove
public void makeMove(int x, int y, byte player)Make a move on the game board.- Specified by:
 makeMovein interfaceGameSearch- Parameters:
 x- The y-coordinate of the move.y- The x-coordinate of the move.player- The player making the move.
 
- 
makeHelpMove
public void makeHelpMove(int x, int y, byte player)Make a helper move on the game board.- Specified by:
 makeHelpMovein interfaceGameSearch- Parameters:
 x- The x-coordinate of the helper move.y- The y-coordinate of the helper move.player- The player making the helper move.
 
- 
playHelpMove
public boolean playHelpMove(int x, int y)Play a move on the game board for a helper move.- Specified by:
 playHelpMovein interfaceGameSearch- 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.
 
 
- 
playMove
public boolean playMove(int x, int y)Play a move on the game board.- Specified by:
 playMovein interfaceGameSearch- 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.
 
 
- 
heuristic
public int heuristic(int[] move)
Calculate the heuristic value for a move.- Specified by:
 heuristicin interfaceGameSearch- Parameters:
 move- An array containing the move coordinates and value.- Returns:
 - The heuristic value for the move.
 
 
- 
maxValue
public 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.- Specified by:
 maxValuein interfaceGameSearch- 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
public 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.- Specified by:
 minValuein interfaceGameSearch- 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
public int[] minmax(java.lang.String[][] state, int depth, boolean myMove, int[] alpha, int[] beta)Perform a minimax search on the game state.- Specified by:
 minmaxin interfaceGameSearch- 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.
 
 
 - 
 
 -