nmrugg / stockfish.js

The Stockfish chess engine in Javascript
GNU General Public License v3.0
906 stars 129 forks source link

Bug about promotion to Queen #50

Closed Arpan90 closed 2 years ago

Arpan90 commented 3 years ago

issue

let notation = "d2d4 e7e6 e2e4 b8c6 b1c3 g8e7 g1f3 a7a6 d4d5 c6b8 f1c4 c7c6 d5d6 b7b5 d6e7 d8b6 e7f8 e8f8 a2a3";

stockfish.send = stockfish.postMessage; stockfish.send(position startpos moves ${notation}); stockfish.send(go depth 15); stockfish.onmessage = function(event) { //NOTE: Web Workers wrap the response in an object. // console.log(event.data ? event.data : event); if(event.data){ if(event.data.includes("bestmove")){ console.log(event.data.split(" ")[1]) // output line } } else{ console.log("event is: ", event); } };

Output line spits this result: e7f8q

This has been the result since the black's move: d8b6 Even after making the suggested move: e7f8q, followed by one more move from black and white each(e8f8 and a2a3), the engine is still stuck at the same suggestion.

Arpan90 commented 2 years ago

Sorry, missed the lack of 'q' after 'e7f8' in notation variable. It so happens that chess.js(which I was using to get the move history for notation variable) tends to follow the square notation like stockfish.js but omits the information about promotions. That information is included as a separate key in the object, not appended to the move itself, unlike stockfish.js