Skip to content

Commit

Permalink
Disable PV parsing. (no arrows or pv board)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonnold committed Jul 24, 2023
1 parent 9911a53 commit 50e1648
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,36 +149,10 @@ class Handler {
this._game[color].nodes = parseInt(rest[3]);
this._game[color].usedTime = parseInt(rest[2]) * 10;

const pvPlayout = new Chess();
pvPlayout.loadPgn(this._game.instance.pgn());

const pv = rest.slice(4);
const parsed = new Array<string>();
const pvAlg = new Array<string>();

// If the PV is not for the current STM then we undo the last move
// and attempt to parse the PV from that position. This will happen when
// the final pv is sent after the best move was sent. (See issue #9)
if (!color.startsWith(pvPlayout.turn())) pvPlayout.undo();

for (let i = 0; i < pv.length; i++) {
const alg = pv[i];
try {
const move = pvPlayout.move(alg, { strict: false });

parsed.push(move.san);
pvAlg.push(`${move.from}${move.to}`);
} catch (err) {
break; // failed to parse a move
}
}

// Only if we could parse at least 1 do
if (parsed.length) {
this._game[color].pv = parsed;
this._game[color].pvAlg = pvAlg;
this._game[color].pvFen = pvPlayout.fen();
}
this._game[color].pv = pv;
this._game[color].pvAlg = [];
this._game[color].pvFen = 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1';

logger.info(
`Updated game ${this._game.name} - Color: ${color}, Depth: ${this._game[color].depth}, Score: ${this._game[color].score}, Nodes: ${this._game[color].nodes}, UsedTime: ${this._game[color].usedTime}`,
Expand Down

0 comments on commit 50e1648

Please sign in to comment.