stockfish.js icon indicating copy to clipboard operation
stockfish.js copied to clipboard

Readable output from Stockfish 10.

Open spinor8 opened this issue 5 years ago • 1 comments

I am currently running Stuckfish the following way.

var stockfish = new Worker("stockfish.js");
stockfish.postMessage("position fen " + currfen)
stockfish.postMessage("go depth 21");
stockfish.onmessage = function(event) {
    console.log(event.data ? event.data : event);
}

Of course the output is very messy. Two questions. Is there a way to filter to the best line calculated so far? Also, the lines are usually in long algebraic notation, is there a way to use short algebraic notation? Thanks.

spinor8 avatar May 28 '19 08:05 spinor8

About the first question, in my project, I use a simple string matching of the incoming message. Something like this:

stockfish.onmessage = function(e) {
  if (typeof e !== 'string') return;
  if (e.startsWith('bestmove')) {
    const bestMove = e.split(' ')[1];
  }
}

pavel-karpovich avatar Jun 07 '19 17:06 pavel-karpovich