statistiques de complexite
This commit is contained in:
parent
f673ed86fb
commit
56b97547b1
@ -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());
|
||||
|
@ -16,6 +16,7 @@ public class AlphaBetaPlayer extends Player{
|
||||
Pair<Point, Point> bestMove = null;
|
||||
for(Pair<Point, Point> 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;
|
||||
|
@ -33,6 +33,7 @@ public class NegamaxPlayer extends Player {
|
||||
int m = Integer.MIN_VALUE;
|
||||
for (Pair<Point, Point> move : state.getMove(state.getCurrentPlayer())) {
|
||||
State nextState = state.play(move);
|
||||
complexity++;
|
||||
m= Math.max(m,-negamax(nextState,depth-1));
|
||||
}
|
||||
return m;
|
||||
|
@ -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<Point, Point> play(State board);
|
||||
|
Loading…
Reference in New Issue
Block a user