33 lines
828 B
Java
33 lines
828 B
Java
package chess.ai.alphabeta;
|
|
import chess.ai.ais.AlphaBetaAI;
|
|
|
|
/**
|
|
* Print the action of an alpha-beta bot on the console.
|
|
* @see AlphaBetaAI
|
|
*/
|
|
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");
|
|
});
|
|
}
|
|
|
|
public AlphaBetaConsolePrinter(AlphaBetaAI ai) {
|
|
this.ai = ai;
|
|
}
|
|
}
|