diff --git a/javaAPI/.~lock.arena_results.csv# b/javaAPI/.~lock.arena_results.csv# new file mode 100644 index 0000000..e43af1b --- /dev/null +++ b/javaAPI/.~lock.arena_results.csv# @@ -0,0 +1 @@ +,vaisse,salle235-12,06.02.2026 11:29,file:///export/home/an23/vaisse/.config/libreoffice/4; \ No newline at end of file diff --git a/javaAPI/fr/iut_fbleau/GameAPI/AbstractGamePlayer.java b/javaAPI/fr/iut_fbleau/GameAPI/AbstractGamePlayer.java index c459eab..9b9e244 100644 --- a/javaAPI/fr/iut_fbleau/GameAPI/AbstractGamePlayer.java +++ b/javaAPI/fr/iut_fbleau/GameAPI/AbstractGamePlayer.java @@ -26,5 +26,6 @@ public abstract class AbstractGamePlayer { * @throws IllegalStateException if the Situation is already in the bookmarks */ public abstract AbstractPly giveYourMove(IBoard p); + public abstract Boolean jesuisMinimax(); } diff --git a/javaAPI/fr/iut_fbleau/HexGame/Arena.java b/javaAPI/fr/iut_fbleau/HexGame/Arena.java index 379fc11..c2e2182 100644 --- a/javaAPI/fr/iut_fbleau/HexGame/Arena.java +++ b/javaAPI/fr/iut_fbleau/HexGame/Arena.java @@ -59,6 +59,6 @@ public class Arena { players.put(Player.PLAYER2, bot2); Simulation simulation = new Simulation(board, players); - return simulation.run(); + return simulation.runForArena(); } } diff --git a/javaAPI/fr/iut_fbleau/HexGame/ArenaMain.java b/javaAPI/fr/iut_fbleau/HexGame/ArenaMain.java index 013ac80..e0b9b8a 100644 --- a/javaAPI/fr/iut_fbleau/HexGame/ArenaMain.java +++ b/javaAPI/fr/iut_fbleau/HexGame/ArenaMain.java @@ -9,7 +9,7 @@ public class ArenaMain { try { size = Integer.parseInt(args[0]); } catch (NumberFormatException ignored) {} } Arena arena = new Arena(size); - arena.addBot(new RandomBot(Player.PLAYER1, 12345L)); // Correct constructor usage + arena.addBot(new RandomBot(Player.PLAYER1, 24015L)); // Correct constructor usage arena.addBot(new MiniMaxBot(Player.PLAYER2)); arena.addBot(new HeuristicBot(Player.PLAYER1)); arena.addBot(new MonteCarloBot(Player.PLAYER2)); // Correct constructor usage diff --git a/javaAPI/fr/iut_fbleau/HexGame/HeuristicBot.java b/javaAPI/fr/iut_fbleau/HexGame/HeuristicBot.java index 8c9c4c2..169a335 100644 --- a/javaAPI/fr/iut_fbleau/HexGame/HeuristicBot.java +++ b/javaAPI/fr/iut_fbleau/HexGame/HeuristicBot.java @@ -8,6 +8,10 @@ public class HeuristicBot extends AbstractGamePlayer { super(me); // Correct constructor usage } + public Boolean jesuisMinimax(){ + return false; + } + @Override public AbstractPly giveYourMove(IBoard board) { HexBoard hb = (HexBoard) board; diff --git a/javaAPI/fr/iut_fbleau/HexGame/HumanConsolePlayer.java b/javaAPI/fr/iut_fbleau/HexGame/HumanConsolePlayer.java index 63068fc..49886f2 100644 --- a/javaAPI/fr/iut_fbleau/HexGame/HumanConsolePlayer.java +++ b/javaAPI/fr/iut_fbleau/HexGame/HumanConsolePlayer.java @@ -18,6 +18,10 @@ public class HumanConsolePlayer extends AbstractGamePlayer { this.in = in; } + public Boolean jesuisMinimax(){ + return false; + } + @Override public AbstractPly giveYourMove(IBoard board) { if (!(board instanceof HexBoard)) { diff --git a/javaAPI/fr/iut_fbleau/HexGame/MiniMaxBot.java b/javaAPI/fr/iut_fbleau/HexGame/MiniMaxBot.java index d23ab50..dfa9d81 100644 --- a/javaAPI/fr/iut_fbleau/HexGame/MiniMaxBot.java +++ b/javaAPI/fr/iut_fbleau/HexGame/MiniMaxBot.java @@ -10,6 +10,10 @@ public class MiniMaxBot extends AbstractGamePlayer { super(me); // Correct constructor usage } + public Boolean jesuisMinimax(){ + return true; + } + @Override public AbstractPly giveYourMove(IBoard board) { HexBoard hb = (HexBoard) board; diff --git a/javaAPI/fr/iut_fbleau/HexGame/MonteCarloBot.java b/javaAPI/fr/iut_fbleau/HexGame/MonteCarloBot.java index 6935120..333b655 100644 --- a/javaAPI/fr/iut_fbleau/HexGame/MonteCarloBot.java +++ b/javaAPI/fr/iut_fbleau/HexGame/MonteCarloBot.java @@ -12,6 +12,10 @@ public class MonteCarloBot extends AbstractGamePlayer { super(me); // Correct constructor usage } + public Boolean jesuisMinimax(){ + return false; + } + @Override public AbstractPly giveYourMove(IBoard board) { HexBoard hb = (HexBoard) board; diff --git a/javaAPI/fr/iut_fbleau/HexGame/RandomBot.java b/javaAPI/fr/iut_fbleau/HexGame/RandomBot.java index b670ada..8d29af7 100644 --- a/javaAPI/fr/iut_fbleau/HexGame/RandomBot.java +++ b/javaAPI/fr/iut_fbleau/HexGame/RandomBot.java @@ -19,6 +19,10 @@ public class RandomBot extends AbstractGamePlayer { this.rng = rng; } + public Boolean jesuisMinimax(){ + return false; + } + public RandomBot(Player me, long seed) { this(me, new Random(seed)); } diff --git a/javaAPI/fr/iut_fbleau/HexGame/Simulation.java b/javaAPI/fr/iut_fbleau/HexGame/Simulation.java index 6fbc9bd..95ad2ac 100644 --- a/javaAPI/fr/iut_fbleau/HexGame/Simulation.java +++ b/javaAPI/fr/iut_fbleau/HexGame/Simulation.java @@ -57,8 +57,8 @@ public class Simulation extends AbstractGame { ctaken = taken; count = 0; } - System.out.println(" wins : "+wins+"/losses : "+losses); - System.out.println(" eval : "+(wins-losses)/EVALDEPTH); + //System.out.println(" wins : "+wins+"/losses : "+losses); + //System.out.println(" eval : "+(wins-losses)/EVALDEPTH); return (wins-losses)/EVALDEPTH; } @@ -232,9 +232,7 @@ public class Simulation extends AbstractGame { } return bestcase; } - } - - + } private AbstractPly GiveBestMove(IBoard board) { @@ -269,5 +267,27 @@ public class Simulation extends AbstractGame { return simCurrentBoard.getResult(); } + public Result runForArena(){ + while(!simCurrentBoard.isGameOver()){ + AbstractGamePlayer player = simmapPlayers.get(simCurrentBoard.getCurrentPlayer()); + IBoard board = simCurrentBoard.safeCopy(); + AbstractPly ply; + if(player.jesuisMinimax()){ + ply = GiveBestMove(board); + } else { + ply = player.giveYourMove(board); + } + HexPly concretePly = (HexPly) ply; + + if (simCurrentBoard.isLegal(ply)) { + simCurrentBoard.doPly(ply); + taken.add(new Integer[]{concretePly.getRow(), concretePly.getCol()}); + System.out.println("Player "+player+" goes ("+concretePly.getRow()+","+concretePly.getCol()+")"); + } + else throw new IllegalStateException("Player "+ player + " is a bloody cheat. He tried playing : "+concretePly.getRow()+","+concretePly.getCol()+" I give up."); + } + return simCurrentBoard.getResult(); + } + }