Initial commit — sujet TP1 IIA (Minimax / Alpha-Beta)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
84
src/main/java/iialib/games/algs/algorithms/MiniMax.java
Normal file
84
src/main/java/iialib/games/algs/algorithms/MiniMax.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package iialib.games.algs.algorithms;
|
||||
|
||||
import iialib.games.algs.GameAlgorithm;
|
||||
import iialib.games.algs.IHeuristic;
|
||||
import iialib.games.model.IBoard;
|
||||
import iialib.games.model.IMove;
|
||||
import iialib.games.model.IRole;
|
||||
|
||||
public class MiniMax<Move extends IMove,Role extends IRole,Board extends IBoard<Move,Role,Board>> implements GameAlgorithm<Move,Role,Board> {
|
||||
|
||||
// Constants
|
||||
/** Defaut value for depth limit
|
||||
*/
|
||||
private final static int DEPTH_MAX_DEFAUT = 4;
|
||||
|
||||
// Attributes
|
||||
/** Role of the max player
|
||||
*/
|
||||
private final Role playerMaxRole;
|
||||
|
||||
/** Role of the min player
|
||||
*/
|
||||
private final Role playerMinRole;
|
||||
|
||||
/** Algorithm max depth
|
||||
*/
|
||||
private int depthMax = DEPTH_MAX_DEFAUT;
|
||||
|
||||
|
||||
/** Heuristic used by the max player
|
||||
*/
|
||||
private IHeuristic<Board, Role> h;
|
||||
|
||||
//
|
||||
/** number of internal visited (developed) nodes (for stats)
|
||||
*/
|
||||
private int nbNodes;
|
||||
|
||||
/** number of leaves nodes nodes (for stats)
|
||||
|
||||
*/
|
||||
private int nbLeaves;
|
||||
|
||||
// --------- Constructors ---------
|
||||
|
||||
public MiniMax(Role playerMaxRole, Role playerMinRole, IHeuristic<Board, Role> h) {
|
||||
this.playerMaxRole = playerMaxRole;
|
||||
this.playerMinRole = playerMinRole;
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
//
|
||||
public MiniMax(Role playerMaxRole, Role playerMinRole, IHeuristic<Board, Role> h, int depthMax) {
|
||||
this(playerMaxRole, playerMinRole, h);
|
||||
this.depthMax = depthMax;
|
||||
}
|
||||
|
||||
/*
|
||||
* IAlgo METHODS =============
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Move bestMove(Board board, Role playerRole) {
|
||||
System.out.println("[MiniMax]");
|
||||
|
||||
Move bestMove = null;
|
||||
// TODO
|
||||
return bestMove;
|
||||
}
|
||||
|
||||
/*
|
||||
* PUBLIC METHODS ==============
|
||||
*/
|
||||
|
||||
public String toString() {
|
||||
return "MiniMax(ProfMax=" + depthMax + ")";
|
||||
}
|
||||
|
||||
/*
|
||||
* PRIVATE METHODS ===============
|
||||
*/
|
||||
|
||||
//TODO
|
||||
}
|
||||
Reference in New Issue
Block a user