stockfish.js
stockfish.js copied to clipboard
What am I doing wrong with moving a piece?
So we have position.
/* Note: */s.send = s.postMessage;
So I've created a new game already and did the startpos.
s.send(`position startpos moves e2e4`);
s.send(`go depth 15`);
returns e2e4
...
Trying to get it to move so when I call go again. It thinks of a new move so I can then do something like:
s.send(`position ${chess.fen()} moves e7e6`);
use this:
s.send(`position fen ${chess.fen()}`);
fen
should be the starting position fen. You can use startpos
for short.
s.send(`position startpos moves e2e4 e7e6`);
moves
just keeps getting longer as the game progresses.
You can send the current fen, like ms6rb said. However, doing so will make three-fold repetition impossible for the engine to calculate, so you should avoid that whenever possible.