diff --git a/src/othello/Main.java b/src/othello/Main.java index cd4177b..f0eb560 100644 --- a/src/othello/Main.java +++ b/src/othello/Main.java @@ -13,10 +13,13 @@ public class Main { State game = new State(board, p1, p2); System.out.println("joueur 1: " + p1); System.out.println("joueur 2: " + p2); + int tour = 0; // Pour le rapport while(!game.isOver()) { Player player = game.getCurrentPlayer(); System.out.println(game.toString()); game = game.play(player.play(game)); + System.out.println("Tour "+tour+" ; complex : "+player.getComplexity()); + tour++; } System.out.println(game.toString()); System.out.println(game.getN1()+" "+ game.getN2()); diff --git a/src/othello/players/AlphaBetaPlayer.java b/src/othello/players/AlphaBetaPlayer.java index e0b22b8..d12a9b4 100644 --- a/src/othello/players/AlphaBetaPlayer.java +++ b/src/othello/players/AlphaBetaPlayer.java @@ -16,6 +16,7 @@ public class AlphaBetaPlayer extends Player{ Pair bestMove = null; for(Pair move : game.getMove(game.getCurrentPlayer())) { State nextState = game.play(move); + complexity++; int value = -alphabeta(nextState, this.depth,Integer.MIN_VALUE,Integer.MAX_VALUE); if (value > bestValue) { bestValue = value; diff --git a/src/othello/players/NegamaxPlayer.java b/src/othello/players/NegamaxPlayer.java index 4913acd..82698ad 100644 --- a/src/othello/players/NegamaxPlayer.java +++ b/src/othello/players/NegamaxPlayer.java @@ -33,6 +33,7 @@ public class NegamaxPlayer extends Player { int m = Integer.MIN_VALUE; for (Pair move : state.getMove(state.getCurrentPlayer())) { State nextState = state.play(move); + complexity++; m= Math.max(m,-negamax(nextState,depth-1)); } return m; diff --git a/src/othello/players/Player.java b/src/othello/players/Player.java index f7ee887..8d7fdaf 100644 --- a/src/othello/players/Player.java +++ b/src/othello/players/Player.java @@ -7,9 +7,15 @@ import othello.State; public abstract class Player { protected final int depth; + protected int complexity; public Player(int depth) { this.depth = depth; + this.complexity = 0; + } + + public int getComplexity () { + return this.complexity; } public abstract Pair play(State board);