feat : add live position evaluation

This commit is contained in:
GuillaumeSD
2024-02-24 21:05:45 +01:00
parent 7b328d3159
commit 1f748f99ca
8 changed files with 220 additions and 105 deletions

View File

@@ -57,3 +57,23 @@ export const getGameToSave = (game: Chess, board: Chess): Chess => {
return board;
};
export const moveLineUciToSan = (
fen: string
): ((moveUci: string) => string) => {
const game = new Chess(fen);
return (moveUci: string): string => {
try {
const move = game.move({
from: moveUci.slice(0, 2),
to: moveUci.slice(2, 4),
promotion: moveUci.slice(4, 5) || undefined,
});
return move.san;
} catch (e) {
return moveUci;
}
};
};