fix : improve brilliant move classification
This commit is contained in:
@@ -197,9 +197,14 @@ export const getIsPieceSacrifice = (
|
|||||||
}
|
}
|
||||||
let nonCapturingMovesTemp = 1;
|
let nonCapturingMovesTemp = 1;
|
||||||
|
|
||||||
|
const capturedPieces: { w: PieceSymbol[]; b: PieceSymbol[] } = {
|
||||||
|
w: [],
|
||||||
|
b: [],
|
||||||
|
};
|
||||||
for (const move of moves) {
|
for (const move of moves) {
|
||||||
const fullMove = game.move(uciMoveParams(move));
|
const fullMove = game.move(uciMoveParams(move));
|
||||||
if (fullMove.captured) {
|
if (fullMove.captured) {
|
||||||
|
capturedPieces[fullMove.color].push(fullMove.captured);
|
||||||
nonCapturingMovesTemp = 1;
|
nonCapturingMovesTemp = 1;
|
||||||
} else {
|
} else {
|
||||||
nonCapturingMovesTemp--;
|
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 endingMaterialDifference = getMaterialDifference(game.fen());
|
||||||
|
|
||||||
const materialDiff = endingMaterialDifference - startingMaterialDifference;
|
const materialDiff = endingMaterialDifference - startingMaterialDifference;
|
||||||
|
|||||||
@@ -153,8 +153,9 @@ const isBrilliantMove = (
|
|||||||
lastPositionAlternativeLineWinPercentage,
|
lastPositionAlternativeLineWinPercentage,
|
||||||
isWhiteMove
|
isWhiteMove
|
||||||
)
|
)
|
||||||
)
|
) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -165,8 +166,8 @@ const isLosingOrAlternateCompletelyWinning = (
|
|||||||
isWhiteMove: boolean
|
isWhiteMove: boolean
|
||||||
): boolean => {
|
): boolean => {
|
||||||
const isLosing = isWhiteMove
|
const isLosing = isWhiteMove
|
||||||
? positionWinPercentage < 45
|
? positionWinPercentage < 50
|
||||||
: positionWinPercentage > 55;
|
: positionWinPercentage > 50;
|
||||||
const isAlternateCompletelyWinning = isWhiteMove
|
const isAlternateCompletelyWinning = isWhiteMove
|
||||||
? lastPositionAlternativeLineWinPercentage > 97
|
? lastPositionAlternativeLineWinPercentage > 97
|
||||||
: lastPositionAlternativeLineWinPercentage < 3;
|
: lastPositionAlternativeLineWinPercentage < 3;
|
||||||
@@ -202,8 +203,9 @@ const isGreatMove = (
|
|||||||
lastPositionAlternativeLineWinPercentage,
|
lastPositionAlternativeLineWinPercentage,
|
||||||
isWhiteMove
|
isWhiteMove
|
||||||
)
|
)
|
||||||
)
|
) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const hasChangedGameOutcome = getHasChangedGameOutcome(
|
const hasChangedGameOutcome = getHasChangedGameOutcome(
|
||||||
lastPositionWinPercentage,
|
lastPositionWinPercentage,
|
||||||
|
|||||||
Reference in New Issue
Block a user