fix : analysis with stalemate game
This commit is contained in:
@@ -147,6 +147,11 @@ export const getEvaluationBarValue = (
|
|||||||
return { whiteBarPercentage, label };
|
return { whiteBarPercentage, label };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getIsStalemate = (fen: string): boolean => {
|
||||||
|
const game = new Chess(fen);
|
||||||
|
return game.isStalemate();
|
||||||
|
};
|
||||||
|
|
||||||
export const getWhoIsCheckmated = (fen: string): "w" | "b" | null => {
|
export const getWhoIsCheckmated = (fen: string): "w" | "b" | null => {
|
||||||
const game = new Chess(fen);
|
const game = new Chess(fen);
|
||||||
if (!game.isCheckmate()) return null;
|
if (!game.isCheckmate()) return null;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
parseEvaluationResults,
|
parseEvaluationResults,
|
||||||
} from "./helpers/parseResults";
|
} from "./helpers/parseResults";
|
||||||
import { computeAccuracy } from "./helpers/accuracy";
|
import { computeAccuracy } from "./helpers/accuracy";
|
||||||
import { getWhoIsCheckmated } from "../chess";
|
import { getIsStalemate, getWhoIsCheckmated } from "../chess";
|
||||||
import { getLichessEval } from "../lichess";
|
import { getLichessEval } from "../lichess";
|
||||||
import { getMovesClassification } from "./helpers/moveClassification";
|
import { getMovesClassification } from "./helpers/moveClassification";
|
||||||
import { EngineWorker } from "@/types/engine";
|
import { EngineWorker } from "@/types/engine";
|
||||||
@@ -158,6 +158,22 @@ export class UciEngine {
|
|||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isStalemate = getIsStalemate(fen);
|
||||||
|
if (isStalemate) {
|
||||||
|
positions.push({
|
||||||
|
lines: [
|
||||||
|
{
|
||||||
|
pv: [],
|
||||||
|
depth: 0,
|
||||||
|
multiPv: 1,
|
||||||
|
cp: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const result = await this.evaluatePosition(fen, depth);
|
const result = await this.evaluatePosition(fen, depth);
|
||||||
positions.push(result);
|
positions.push(result);
|
||||||
setEvaluationProgress?.(
|
setEvaluationProgress?.(
|
||||||
|
|||||||
Reference in New Issue
Block a user