likeawizard / chess-go

Chess engine with lichess.org bot-play integration. Discontinued. Further development migrated to https://github.com/likeawizard/tofiks
2 stars 0 forks source link

Bug: engine attempted to play illegal move #62

Open likeawizard opened 2 years ago

likeawizard commented 2 years ago

https://lichess.org/0PehuAWg/white

f3f4 is impossible as there is no piece on f3 at all.

My turn in 0PehuAWg. (FEN: 8/6pp/2p2nb1/3pn3/5P1P/2k5/p3P1B1/2K3NR w - - 0 1) Thinking... TimeManagment: time to think:2270, effective lag: 500 Depth: 1 (2.93) Move: [f4e5] (72.4knps, total: 16.0 (1.0 15.0), QN: 93%, evals: 93%) Depth: 2 (1.65) Move: [h1h3 e5d3] (86.3knps, total: 186.0 (16.0 170.0), QN: 91%, evals: 91%) Depth: 3 (1.65) Move: [h1h3 e5d3 e2d3] (93.1knps, total: 705.0 (63.0 642.0), QN: 91%, evals: 92%) Depth: 4 (-2.45) Move: [h1h3 e5d3 h3d3 g6d3] (139.5knps, total: 5.3k (370.0 4.9k), QN: 92%, evals: 93%) Depth: 5 (-2.45) Move: [h1h3 g6d3 h3d3 e5d3 e2d3] (155.2knps, total: 34.6k (1.9k 32.7k), QN: 94%, evals: 94%) Depth: 6 (#4) Move: [f3f4 e5g4 h1h3 c3b4 g1f3 g6e4] (309.3knps, total: 181.6k (10.1k 171.5k), QN: 94%, evals: 94%) Playing f3f4 in 0PehuAWg (FEN: 8/6pp/2p2nb1/3pn3/5P1P/2k5/p3P1B1/2K3NR w - - 0 1)

likeawizard commented 2 years ago

Probably caused by out-of-order handling of events:

  1. bot sends move to lichess
  2. bot receives updated board state after the move is made
  3. update internal state with lichess state
  4. opponent makes move and event is sent with the updated board
  5. update internal state with lichess state Due to asynchronous execution it is possible that 2 & 4 are received out of order especially if opponent plays the move instantaneously. Thus updating the internal state with 4. beofre it is updated with 2. can cause the internal state be corrupted or out of sync.