legitbugfix #19
1
javaAPI/.~lock.arena_results.csv#
Normal file
1
javaAPI/.~lock.arena_results.csv#
Normal file
@@ -0,0 +1 @@
|
|||||||
|
,vaisse,salle235-12,06.02.2026 11:29,file:///export/home/an23/vaisse/.config/libreoffice/4;
|
||||||
@@ -26,5 +26,6 @@ public abstract class AbstractGamePlayer {
|
|||||||
* @throws IllegalStateException if the Situation is already in the bookmarks
|
* @throws IllegalStateException if the Situation is already in the bookmarks
|
||||||
*/
|
*/
|
||||||
public abstract AbstractPly giveYourMove(IBoard p);
|
public abstract AbstractPly giveYourMove(IBoard p);
|
||||||
|
public abstract Boolean jesuisMinimax();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,6 @@ public class Arena {
|
|||||||
players.put(Player.PLAYER2, bot2);
|
players.put(Player.PLAYER2, bot2);
|
||||||
|
|
||||||
Simulation simulation = new Simulation(board, players);
|
Simulation simulation = new Simulation(board, players);
|
||||||
return simulation.run();
|
return simulation.runForArena();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class ArenaMain {
|
|||||||
try { size = Integer.parseInt(args[0]); } catch (NumberFormatException ignored) {}
|
try { size = Integer.parseInt(args[0]); } catch (NumberFormatException ignored) {}
|
||||||
}
|
}
|
||||||
Arena arena = new Arena(size);
|
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 MiniMaxBot(Player.PLAYER2));
|
||||||
arena.addBot(new HeuristicBot(Player.PLAYER1));
|
arena.addBot(new HeuristicBot(Player.PLAYER1));
|
||||||
arena.addBot(new MonteCarloBot(Player.PLAYER2)); // Correct constructor usage
|
arena.addBot(new MonteCarloBot(Player.PLAYER2)); // Correct constructor usage
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ public class HeuristicBot extends AbstractGamePlayer {
|
|||||||
super(me); // Correct constructor usage
|
super(me); // Correct constructor usage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean jesuisMinimax(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractPly giveYourMove(IBoard board) {
|
public AbstractPly giveYourMove(IBoard board) {
|
||||||
HexBoard hb = (HexBoard) board;
|
HexBoard hb = (HexBoard) board;
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ public class HumanConsolePlayer extends AbstractGamePlayer {
|
|||||||
this.in = in;
|
this.in = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean jesuisMinimax(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractPly giveYourMove(IBoard board) {
|
public AbstractPly giveYourMove(IBoard board) {
|
||||||
if (!(board instanceof HexBoard)) {
|
if (!(board instanceof HexBoard)) {
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ public class MiniMaxBot extends AbstractGamePlayer {
|
|||||||
super(me); // Correct constructor usage
|
super(me); // Correct constructor usage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean jesuisMinimax(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractPly giveYourMove(IBoard board) {
|
public AbstractPly giveYourMove(IBoard board) {
|
||||||
HexBoard hb = (HexBoard) board;
|
HexBoard hb = (HexBoard) board;
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ public class MonteCarloBot extends AbstractGamePlayer {
|
|||||||
super(me); // Correct constructor usage
|
super(me); // Correct constructor usage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean jesuisMinimax(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractPly giveYourMove(IBoard board) {
|
public AbstractPly giveYourMove(IBoard board) {
|
||||||
HexBoard hb = (HexBoard) board;
|
HexBoard hb = (HexBoard) board;
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ public class RandomBot extends AbstractGamePlayer {
|
|||||||
this.rng = rng;
|
this.rng = rng;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean jesuisMinimax(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public RandomBot(Player me, long seed) {
|
public RandomBot(Player me, long seed) {
|
||||||
this(me, new Random(seed));
|
this(me, new Random(seed));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ public class Simulation extends AbstractGame {
|
|||||||
ctaken = taken;
|
ctaken = taken;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
System.out.println(" wins : "+wins+"/losses : "+losses);
|
//System.out.println(" wins : "+wins+"/losses : "+losses);
|
||||||
System.out.println(" eval : "+(wins-losses)/EVALDEPTH);
|
//System.out.println(" eval : "+(wins-losses)/EVALDEPTH);
|
||||||
return (wins-losses)/EVALDEPTH;
|
return (wins-losses)/EVALDEPTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,9 +232,7 @@ public class Simulation extends AbstractGame {
|
|||||||
}
|
}
|
||||||
return bestcase;
|
return bestcase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private AbstractPly GiveBestMove(IBoard board) {
|
private AbstractPly GiveBestMove(IBoard board) {
|
||||||
@@ -269,5 +267,27 @@ public class Simulation extends AbstractGame {
|
|||||||
return simCurrentBoard.getResult();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user