bug fixes and first try of github docker

This commit is contained in:
Stefan
2025-11-23 16:43:47 +01:00
parent 74016f08c6
commit 0aa4370f64
12 changed files with 695 additions and 350 deletions
+10 -1
View File
@@ -27,7 +27,7 @@ export class Stockfish {
}
async evaluate(fen: string, depth: number = 15, multiPV: number = 1): Promise<StockfishEvaluation> {
return new Promise((resolve, reject) => {
return new Promise<StockfishEvaluation>((resolve, reject) => {
if (!this.worker) {
reject("Stockfish worker not initialized");
return;
@@ -81,6 +81,15 @@ export class Stockfish {
this.worker.addEventListener("message", handler);
this.worker.postMessage(`position fen ${fen}`);
this.worker.postMessage(`go depth ${depth}`);
}).then((evalResult: StockfishEvaluation) => {
// Normalize score to be from White's perspective
// Stockfish returns score relative to side to move
const sideToMove = fen.split(" ")[1]; // 'w' or 'b'
if (sideToMove === 'b') {
if (evalResult.score !== 0) evalResult.score = -evalResult.score;
if (evalResult.mate !== null && evalResult.mate !== 0) evalResult.mate = -evalResult.mate;
}
return evalResult;
});
}