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
protected void play() {
long current = System.currentTimeMillis();
Move move = getBestMove();
long elapsed = System.currentTimeMillis() - current;
System.out.println("Took " + elapsed + "ms");
sendCommand(new MoveCommand(move));
}

View File

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