Initial commit — sujet TP1 IIA (Minimax / Alpha-Beta)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
kerboul
2026-04-07 14:41:05 +02:00
commit 9700af5c65
22 changed files with 885 additions and 0 deletions

View 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
}