feat : add move classification
This commit is contained in:
@@ -37,9 +37,25 @@ export const getLichessEval = async (
|
||||
|
||||
lines.sort(sortLines);
|
||||
|
||||
const bestMove = lines[0].pv[0];
|
||||
const linesToKeep = lines.slice(0, multiPv);
|
||||
|
||||
const isWhiteToPlay = fen.split(" ")[1] === "w";
|
||||
|
||||
if (!isWhiteToPlay) {
|
||||
return {
|
||||
bestMove,
|
||||
lines: linesToKeep.map((line) => ({
|
||||
...line,
|
||||
cp: line.cp ? -line.cp : line.cp,
|
||||
mate: line.mate ? -line.mate : line.mate,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
bestMove: lines[0].pv[0],
|
||||
lines: lines.slice(0, multiPv),
|
||||
bestMove,
|
||||
lines: linesToKeep,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user