fix : improve brilliant move classification
This commit is contained in:
@@ -197,9 +197,14 @@ export const getIsPieceSacrifice = (
|
||||
}
|
||||
let nonCapturingMovesTemp = 1;
|
||||
|
||||
const capturedPieces: { w: PieceSymbol[]; b: PieceSymbol[] } = {
|
||||
w: [],
|
||||
b: [],
|
||||
};
|
||||
for (const move of moves) {
|
||||
const fullMove = game.move(uciMoveParams(move));
|
||||
if (fullMove.captured) {
|
||||
capturedPieces[fullMove.color].push(fullMove.captured);
|
||||
nonCapturingMovesTemp = 1;
|
||||
} else {
|
||||
nonCapturingMovesTemp--;
|
||||
@@ -207,6 +212,19 @@ export const getIsPieceSacrifice = (
|
||||
}
|
||||
}
|
||||
|
||||
for (const p of capturedPieces["w"].slice(0)) {
|
||||
if (capturedPieces["b"].includes(p)) {
|
||||
capturedPieces["b"].splice(capturedPieces["b"].indexOf(p), 1);
|
||||
capturedPieces["w"].splice(capturedPieces["w"].indexOf(p), 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
Math.abs(capturedPieces["w"].length - capturedPieces["b"].length) <= 1 &&
|
||||
capturedPieces["w"].concat(capturedPieces["b"]).every((p) => p === "p")
|
||||
return false;
|
||||
}
|
||||
|
||||
const endingMaterialDifference = getMaterialDifference(game.fen());
|
||||
|
||||
const materialDiff = endingMaterialDifference - startingMaterialDifference;
|
||||
|
||||
Reference in New Issue
Block a user