refactor: alphabeta time printing

This commit is contained in:
2025-05-02 19:56:00 +02:00
parent 64bed4ea3a
commit 16ea1700d8
2 changed files with 5 additions and 3 deletions

View File

@@ -80,10 +80,7 @@ public class AlphaBetaAI extends AI {
@Override @Override
protected void play() { protected void play() {
long current = System.currentTimeMillis();
Move move = getBestMove(); Move move = getBestMove();
long elapsed = System.currentTimeMillis() - current;
System.out.println("Took " + elapsed + "ms");
sendCommand(new MoveCommand(move)); sendCommand(new MoveCommand(move));
} }

View File

@@ -3,16 +3,21 @@ package chess.ai.minimax;
public class AlphaBetaConsolePrinter { public class AlphaBetaConsolePrinter {
private final AlphaBetaAI ai; private final AlphaBetaAI ai;
private long lastTime;
public void connect() { public void connect() {
ai.onStartEval.connect((moveCount) -> { ai.onStartEval.connect((moveCount) -> {
this.lastTime = System.currentTimeMillis();
System.out.println("Evaluating " + moveCount + " moves ..."); System.out.println("Evaluating " + moveCount + " moves ...");
}); });
ai.onProgress.connect((progress) -> { ai.onProgress.connect((progress) -> {
System.out.printf("Progress : %.2f %% \r", progress * 100.0f); System.out.printf("Progress : %.2f %% \r", progress * 100.0f);
}); });
ai.onCompleteEval.connect((bestMove) -> { ai.onCompleteEval.connect((bestMove) -> {
System.out.println("Best move : " + bestMove + " "); System.out.println("Best move : " + bestMove + " ");
System.out.println("Took " + (System.currentTimeMillis() - this.lastTime) + "ms");
}); });
} }