nmrugg / stockfish.js

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

Repeating invalid moves #48

Open WyattSL opened 3 years ago

WyattSL commented 3 years ago

Pretty confident this is a issue with my implementation of stockfish, although I’ve been unable to solve it. I issue everything beginning with a CMD:, and receive everything beginning with MSG:.

When starting a new game, the following occurs:

CMD: uci
CMD: setoption name Contempt value 0
CMD: setoption name Aggressiveness value 100
CMD: setoption name Skill Level Maximum Error value 0
CMD: setoption name Probability value 0
CMD: setoption name Skill Level value 20
CMD: setoption name King Safety value 0
CMD: ucinewgame
CMD: isready
CMD: position startpos moves

MSG: Stockfish.js 10 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott, D. Dugovic, F. Fichter, N. Fiekas, et al.
MSG: id name Stockfish.js 10 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott, D. Dugovic, F. Fichter, N. Fiekas, et al.
MSG:
MSG: option name Debug Log File type string default
MSG: option name Contempt type spin default 24 min -100 max 100
MSG: option name Analysis Contempt type combo default Both var Both var Off var White var Black
MSG: option name Threads type spin default 1 min 1 max 1
MSG: option name Hash type spin default 16 min 16 max 16
MSG: option name Clear Hash type button
MSG: option name Ponder type check default false
MSG: option name MultiPV type spin default 1 min 1 max 500
MSG: option name Skill Level type spin default 20 min 0 max 20
MSG: option name Move Overhead type spin default 30 min 0 max 5000
MSG: option name Minimum Thinking Time type spin default 20 min 0 max 5000
MSG: option name Slow Mover type spin default 84 min 10 max 1000
MSG: option name nodestime type spin default 0 min 0 max 10000
MSG: option name UCI_Chess960 type check default false
MSG: option name UCI_Variant type combo default chess var chess
MSG: option name UCI_AnalyseMode type check default false
MSG: option name Skill Level Maximum Error type spin default 200 min 0 max 5000
MSG: option name Skill Level Probability type spin default 128 min 1 max 1000
MSG: uciok
MSG: No such option: Aggressiveness
MSG: No such option: Probability
MSG: No such option: King Safety
MSG: readyok

I am playing black, with Stockfish playing white. I then move e5, and stockfish will move e4, sending:

CMD: position startpos moves e7e5
CMD: go depth 5
MSG: info depth 1 seldepth 1 multipv 1 score cp 92 nodes 20 nps 714 time 28 pv e2e4 bmc 5
MSG: info depth 2 seldepth 2 multipv 1 score cp 88 nodes 54 nps 1459 time 37 pv e2e4 b7b6 bmc 2.585
MSG: info depth 3 seldepth 3 multipv 1 score cp 172 nodes 137 nps 2914 time 47 pv d2d4 c7c6 e2e4 bmc 2.33645
MSG: info depth 4 seldepth 4 multipv 1 score cp 106 nodes 263 nps 4383 time 60 pv d2d4 e7e6 e2e4 b7b6 bmc 1.20794
MSG: info depth 5 seldepth 5 multipv 1 score cp 62 nodes 1355 nps 13028 time 104 pv e2e4 e7e6 d2d4 d7d5 d1f3 bmc 1.62451
MSG: bestmove e2e4 ponder e7e6

This is all valid. However, if I make any other move, such as a5, this will occur:

CMD: position startpos moves e7e5 e2e4 a7a5
CMD: go depth 5
MSG: info depth 1 seldepth 1 multipv 1 score cp 62 nodes 21 nps 1909 time 11 pv e2e4 bmc 1
MSG: info depth 2 seldepth 2 multipv 1 score cp 62 nodes 43 nps 2047 time 21 pv e2e4 e7e6 bmc 0.517
MSG: info depth 3 seldepth 3 multipv 1 score cp 62 nodes 77 nps 2483 time 31 pv e2e4 e7e6 d2d4 bmc 0.267289
MSG: info depth 4 seldepth 4 multipv 1 score cp 62 nodes 106 nps 2789 time 38 pv e2e4 e7e6 d2d4 d7d5 bmc 0.138188
MSG: info depth 5 seldepth 5 multipv 1 score cp 62 nodes 469 nps 8849 time 53 pv e2e4 e7e6 d2d4 d7d5 bmc 0.0714434
MSG: bestmove e2e4 ponder e7e6
from 5:2 to 5:4
Invalid move!

My implementation does not check the movements stockfish makes, however will verify that a piece is at that location (I.e. stockfish can cheat, but can’t move pieces that don’t exist): It is trying to move e4 almost 30-40 times. When a invalid move is detected, stockfish is told to try again. Stockfish then moved Nc3 I moved h5, and stockfish then constantly tried to move b1c3 which was invalid, as there was no piece in b1:

CMD: position startpos moves e7e5 e2e4 a7a5 b1c3
CMD: go depth 5
MSG: info depth 1 seldepth 1 multipv 1 score cp 40 nodes 22 nps 7333 time 3 pv b1c3 bmc 1
MSG: info depth 2 seldepth 2 multipv 1 score cp 40 nodes 44 nps 11000 time 4 pv b1c3 e7e5 bmc 0.517
MSG: info depth 3 seldepth 3 multipv 1 score cp 40 nodes 70 nps 11666 time 6 pv b1c3 e7e5 d2d4 bmc 0.267289
MSG: info depth 4 seldepth 4 multipv 1 score cp 40 nodes 96 nps 12000 time 8 pv b1c3 e7e5 d2d4 b8c6 bmc 0.138188
MSG: info depth 5 seldepth 5 multipv 1 score cp 40 nodes 132 nps 13200 time 10 pv b1c3 e7e5 d2d4 b8c6 d4e5 bmc 0.0714434
MSG: bestmove b1c3 ponder e7e5
from 2:1 to 3:3
Invalid move!

I would appreciate help on this issue.