feat : add progress bar

This commit is contained in:
GuillaumeSD
2024-03-08 23:56:29 +01:00
parent 91b56fde60
commit 81cbc2ca80
7 changed files with 72 additions and 27 deletions

View File

@@ -100,8 +100,10 @@ export abstract class UciEngine {
uciMoves,
depth = 16,
multiPv = this.multiPv,
setEvaluationProgress,
}: EvaluateGameParams): Promise<GameEval> {
this.throwErrorIfNotReady();
setEvaluationProgress?.(1);
await this.setMultiPv(multiPv);
this.ready = false;
@@ -126,6 +128,9 @@ export abstract class UciEngine {
}
const result = await this.evaluatePosition(fen, depth);
positions.push(result);
setEvaluationProgress?.(
Math.max((fens.indexOf(fen) / fens.length) * 100 - 5, 2)
);
}
const positionsWithClassification = getMovesClassification(
@@ -136,6 +141,7 @@ export abstract class UciEngine {
const accuracy = computeAccuracy(positions);
this.ready = true;
setEvaluationProgress?.(99);
return {
positions: positionsWithClassification,
accuracy,