lichess-bot-devs / lichess-bot

A bridge between Lichess bots and chess engines
GNU Affero General Public License v3.0
745 stars 440 forks source link

incorrect Syzygy move selection allows draw in won position #830

Closed jdart1 closed 1 year ago

jdart1 commented 1 year ago

In this game: https://lichess.org/K9tOivpn/black, Arasan, playing Black, had a won position, but the bot, selecting moves from the Syzygy tablebases, allowed the opponent to draw by repetition.

config.yaml was set up as follows:

  lichess_bot_tbs:           # The tablebases list here will be read by lichess-bot, not the engine.
    syzygy:
      enabled: true
      paths:
        - "/home/jdart/chess/syzygy"
        - "/home/jdart/chess/syzygy-6man/wdl"
        - "/home/jdart/chess/syzygy-6man/dtz"
      max_pieces: 6
      move_quality: "best"   # One of "good", "best", "suggest" (it takes all the "good" moves and tells the engine to only consider these; will move instantly if there is only 1 "good" move).      

The game:

[Event "Rated Rapid game"]
[Site "lichess.org"]
[Date "2023.08.31"]
[Round "?"]
[White "pawn_git"]
[Black "ArasanX"]
[Result "1/2-1/2"]
[ECO "B31"]
[WhiteElo "2573"]
[BlackElo "2862"]
[PlyCount "172"]
[EventDate "2023.??.??"]
[EventType "rapid"]

1. e4 c5 2. Nf3 Nc6 3. Bb5 g6 4. O-O Bg7 5. c3 Nf6 6. Qa4 O-O 7. Re1 e5 8. d3 Qc7 9. Bg5 h6 10. Bxf6 Bxf6 11. Bc4 a6 12. Nbd2 Rb8 13. Qd1 Bg7 14. a4 b5 15. axb5 axb5 16. Ba2 Ne7 17. Nf1 Kh8 18. h4 f5 19. h5 g5 20. exf5 Nxf5 21. Qe2 d6 22. N3d2 Bb7 23. Be6 Qb6 24. Rac1 Qc6 25. Ne3 Nxe3 26. fxe3 d5 27. Bg4 c4 28. d4 Rbe8 29. Nf3 exd4 30. Nxd4 Bxd4 31. cxd4 Kg7 32. Rf1 Bc8 33. Rxf8 Rxf8 34. Re1 Bxg4 35. Qxg4 b4 36. Ra1 Rf7 37. Qg3 Qc7 38. Qxc7 Rxc7 39. g4 Rf7 40. Kg2 b3 41. Ra4 Rf6 42. e4 Rf4 43. Ra7+ Kf6 44. Ra6+ Kf7 45. exd5 Rxg4+ 46. Kf3 Rg1 47. Rc6 g4+ 48. Kf4 Rc1 49. Rxh6 c3 50. bxc3 g3 51. Kxg3 b2 52. Rb6 b1=Q 53. Rxb1 Rxb1 54. Kf4 Rc1 55. d6 Rf1+ 56. Kg5 Rf6 57. d7 Rd6 58. Kf5 Rxd7 59. h6 Rc7 60. h7 Rc8 61. Ke4 Kg6 62. Kd5 Kxh7 63. c4 Kg6 64. c5 Kf6 65. Ke4 Ke6 66. d5+ Kf7 67. c6 Rg8 68. Kd4 Ke7 69. Kc5 Rg5 70. c7 Kd7 71. c8=Q+ Kxc8 72. Kc6 Rg6+ 73. Kc5 Kc7 74. Kd4 Kd6 75. Ke4 Rg5 76. Kf4 Re5 77. Kg4 Kc5 78. d6 Re8 79. d7 Rd8 80. Kf3 Kc6 81. Ke4 Kb7 82. Ke5 Kc6 83. Ke4 Rg8 84. Kd4 Rb8 85. Ke3 Rh8 86. Kd4 Rg8 1/2-1/2

Some of the log file:

2023-08-31 08:40:16,789 __mp_main__ INFO 
2023-08-31 08:40:16,790 __mp_main__ INFO move: 84
2023-08-31 08:40:16,875 engine_wrapper INFO Got move g8b8 from syzygy (wdl: 2, dtz: 13) for game K9tOivpn
2023-08-31 08:40:16,877 chess.engine DEBUG <UciProtocol (pid=11474)>: << stop
2023-08-31 08:40:16,877 engine_wrapper INFO Evaluation: 99.0
2023-08-31 08:40:17,031 urllib3.connectionpool DEBUG https://lichess.org:443 "POST /api/bot/game/K9tOivpn/move/g8b8?offeringDraw=false HTTP/1.1" 200 11
2023-08-31 08:40:17,039 __mp_main__ DEBUG Game state: {'type': 'gameState', 'moves': 'e2e4 c7c5 g1f3 b8c6 f1b5 g7g6 e1g1 f8g7 c2c3 g8f6 d1a4 e8g8 f1e1 e7e5 d2d3 d8c7 c1g5 h7h6 g5f6 g7f6 b5c4 a7a6 b1d2 a8b8 a4d1 f6g7 a2a4 b7b5 a4b5 a6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6c6 f1e3 f5e3 f2e3 d6d5 e6g4 c5c4 d3d4 b8e8 d2f3 e5d4 f3d4 g7d4 c3d4 h8g7 e1f1 b7c8 f1f8 e8f8 c1e1 c8g4 e2g4 b5b4 e1a1 f8f7 g4g3 c6c7 g3c7 f7c7 g2g4 c7f7 g1g2 b4b3 a1a4 f7f6 e3e4 f6f4 a4a7 g7f6 a7a6 f6f7 e4d5 f4g4 g2f3 g4g1 a6c6 g5g4 f3f4 g1c1 c6h6 c4c3 b2c3 g4g3 f4g3 b3b2 h6b6 b2b1q b6b1 c1b1 g3f4 b1c1 d5d6 c1f1 f4g5 f1f6 d6d7 f6d6 g5f5 d6d7 h5h6 d7c7 h6h7 c7c8 f5e4 f7g6 e4d5 g6h7 c3c4 h7g6 c4c5 g6f6 d5e4 f6e6 d4d5 e6f7 c5c6 c8g8 e4d4 f7e7 d4c5 g8g5 c6c7 e7d7 c7c8q d7c8 c5c6 g5g6 c6c5 c8c7 c5d4 c7d6 d4e4 g6g5 e4f4 g5e5 f4g4 d6c5 d5d6 e5e8 d6d7 e8d8 g4f3 c5c6 f3e4 c6b7 e4e5 b7c6 e5e4 d8g8 e4d4 g8b8 d4e3', 'wtime': 5820, 'btime': 310930, 'winc': 3000, 'binc': 3000, 'status': 'started'}
2023-08-31 08:40:20,611 __mp_main__ INFO 
2023-08-31 08:40:20,611 __mp_main__ INFO move: 85
2023-08-31 08:40:20,700 engine_wrapper INFO Got move b8h8 from syzygy (wdl: 2, dtz: 15) for game K9tOivpn
2023-08-31 08:40:20,702 chess.engine DEBUG <UciProtocol (pid=11474)>: << stop
2023-08-31 08:40:20,702 engine_wrapper INFO Evaluation: 99.0
2023-08-31 08:40:20,857 urllib3.connectionpool DEBUG https://lichess.org:443 "POST /api/bot/game/K9tOivpn/move/b8h8?offeringDraw=false HTTP/1.1" 200 11
2023-08-31 08:40:20,866 __mp_main__ DEBUG Game state: {'type': 'gameState', 'moves': 'e2e4 c7c5 g1f3 b8c6 f1b5 g7g6 e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b1d2 a8b8 a4d1 f6g7 a2a4 b7b5 a4b5 a6b5 c4a2 c6e7 d2f1 g8h8 h2h4 f7f5 h4h5 g6g5 e4f5 e7f5 d1e2 d7d6 f3d2 c8b7 a2e6 c7b6 a1c1 b6c6 f1e3 f5e3 f2e3 d6d5 e6g4 c5c4 d3d4 b8e8 d2f3 e5d4 f3d4 g7d4 c3d4 h8g7 e1f1 b7c8 f1f8 e8f8 c1e1 c8g4 e2g4 b5b4 e1a1 f8f7 g4g3 c6c7 g3c7 f7c7 g2g4 c7f7 g1g2 b4b3 a1a4 f7f6 e3e4 f6f4 a4a7 g7f6 a7a6 f6f7 e4d5 f4g4 g2f3 g4g1 a6c6 g5g4 f3f4 g1c1 c6h6 c4c3 b2c3 g4g3 f4g3 b3b2 h6b6 b2b1q b6b1 c1b1 g3f4 b1c1 d5d6 c1f1 f4g5 f1f6 d6d7 f6d6 g5f5 d6d7 h5h6 d7c7 h6h7 c7c8 f5e4 f7g6 e4d5 g6h7 c3c4 h7g6 c4c5 g6f6 d5e4 f6e6 d4d5 e6f7 c5c6 c8g8 e4d4 f7e7 d4c5 g8g5 c6c7 e7d7 c7c8q d7c8 c5c6 g5g6 c6c5 c8c7 c5d4 c7d6 d4e4 g6g5 e4f4 g5e5 f4g4 d6c5 d5d6 e5e8 d6d7 e8d8 g4f3 c5c6 f3e4 c6b7 e4e5 b7c6 e5e4 d8g8 e4d4 g8b8 d4e3 b8h8 e3d4', 'wtime': 5710, 'btime': 313680, 'winc': 3000, 'binc': 3000, 'status': 'started'}
2023-08-31 08:40:23,975 __mp_main__ INFO 
2023-08-31 08:40:23,975 __mp_main__ INFO move: 86
2023-08-31 08:40:24,062 engine_wrapper INFO Got move h8g8 from syzygy (wdl: 2, dtz: 17) for game K9tOivpn
2023-08-31 08:40:24,064 chess.engine DEBUG <UciProtocol (pid=11474)>: << stop
2023-08-31 08:40:24,064 engine_wrapper INFO Evaluation: 99.0
2023-08-31 08:40:24,218 urllib3.connectionpool DEBUG https://lichess.org:443 "POST /api/bot/game/K9tOivpn/move/h8g8?offeringDraw=false HTTP/1.1" 200 11
2023-08-31 08:40:24,226 __mp_main__ DEBUG Game state: {'type': 'gameState', 'moves': 'e2e4 c7c5 g1f3 b8c6 f1b5 g7g6 e1g1 f8g7 c2c3 g8f6 d1a4 e8g8 f1e1 e7e5 d2d3 d8c7 c1g5 h7h6 g5f6 g7f6 b5c4 a7a6 b1d2 a8b8 a4d1 f6g7 a2a4 b7b5 a4b5 a6b5 c4a2 c6e7 d2f1 g8h8 h2h4 f7f5 h4h5 g6g5 e4f5 e7f5 d1e2 d7d6 f3d2 c8b7 a2e6 c7b6 a1c1 b6c6 f1e3 f5e3 f2e3 d6d5 e6g4 c5c4 d3d4 b8e8 d2f3 e5d4 f3d4 g7d4 c3d4 h8g7 e1f1 b7c8 f1f8 e8f8 c1e1 c8g4 e2g4 b5b4 e1a1 f8f7 g4g3 c6c7 g3c7 f7c7 g2g4 c7f7 g1g2 b4b3 a1a4 f7f6 e3e4 f6f4 a4a7 g7f6 a7a6 f6f7 e4d5 f4g4 g2f3 g4g1 a6c6 g5g4 f3f4 g1c1 c6h6 c4c3 b2c3 g4g3 f4g3 b3b2 h6b6 b2b1q b6b1 c1b1 g3f4 b1c1 d5d6 c1f1 f4g5 f1f6 d6d7 f6d6 g5f5 d6d7 h5h6 d7c7 h6h7 c7c8 f5e4 f7g6 e4d5 g6h7 c3c4 h7g6 c4c5 g6f6 d5e4 f6e6 d4d5 e6f7 c5c6 c8g8 e4d4 f7e7 d4c5 g8g5 c6c7 e7d7 c7c8q d7c8 c5c6 g5g6 c6c5 c8c7 c5d4 c7d6 d4e4 g6g5 e4f4 g5e5 f4g4 d6c5 d5d6 e5e8 d6d7 e8d8 g4f3 c5c6 f3e4 c6b7 e4e5 b7c6 e5e4 d8g8 e4d4 g8b8 d4e3 b8h8 e3d4 h8g8', 'wtime': 5710, 'btime': 316430, 'winc': 3000, 'binc': 3000, 'status': 'started'}
2023-08-31 08:40:27,239 __mp_main__ DEBUG Game state: {'type': 'gameState', 'moves': 'e2e4 c7c5 g1f3 b8c6 f1b5 g7g6 e1g1 f8g7 c2c3 g8f6 d1a4 e8g8 f1e1 e7e5 d2d3 d8c7 c1g5 h7h6 g5f6 g7f6 b5c4 a7a6 b1d2 a8b8 a4d1 f6g7 a2a4 b7b5 a4b5 a6b5 c4a2 c6e7 d2f1 g8h8 h2h4 f7f5 h4h5 g6g5 e4f5 e7f5 d1e2 d7d6 f3d2 c8b7 a2e6 c7b6 a1c1 b6c6 f1e3 f5e3 f2e3 d6d5 e6g4 c5c4 d3d4 b8e8 d2f3 e5d4 f3d4 g7d4 c3d4 h8g7 e1f1 b7c8 f1f8 e8f8 c1e1 c8g4 e2g4 b5b4 e1a1 f8f7 g4g3 c6c7 g3c7 f7c7 g2g4 c7f7 g1g2 b4b3 a1a4 f7f6 e3e4 f6f4 a4a7 g7f6 a7a6 f6f7 e4d5 f4g4 g2f3 g4g1 a6c6 g5g4 f3f4 g1c1 c6h6 c4c3 b2c3 g4g3 f4g3 b3b2 h6b6 b2b1q b6b1 c1b1 g3f4 b1c1 d5d6 c1f1 f4g5 f1f6 d6d7 f6d6 g5f5 d6d7 h5h6 d7c7 h6h7 c7c8 f5e4 f7g6 e4d5 g6h7 c3c4 h7g6 c4c5 g6f6 d5e4 f6e6 d4d5 e6f7 c5c6 c8g8 e4d4 f7e7 d4c5 g8g5 c6c7 e7d7 c7c8q d7c8 c5c6 g5g6 c6c5 c8c7 c5d4 c7d6 d4e4 g6g5 e4f4 g5e5 f4g4 d6c5 d5d6 e5e8 d6d7 e8d8 g4f3 c5c6 f3e4 c6b7 e4e5 b7c6 e5e4 d8g8 e4d4 g8b8 d4e3 b8h8 e3d4 h8g8 d4e4', 'wtime': 5690, 'btime': 316430, 'winc': 3000, 'binc': 3000, 'status': 'started'}
2023-08-31 08:40:27,245 __mp_main__ INFO 
2023-08-31 08:40:27,245 __mp_main__ INFO move: 87
2023-08-31 08:40:27,334 engine_wrapper INFO Got move g8b8 from syzygy (wdl: 2, dtz: 19) for game K9tOivpn
2023-08-31 08:40:27,336 chess.engine DEBUG <UciProtocol (pid=11474)>: << stop
2023-08-31 08:40:27,336 engine_wrapper INFO Evaluation: 99.0
2023-08-31 08:40:27,491 urllib3.connectionpool DEBUG https://lichess.org:443 "POST /api/bot/game/K9tOivpn/move/g8b8?offeringDraw=false HTTP/1.1" 200 11
2023-08-31 08:40:27,499 __mp_main__ DEBUG Game state: {'type': 'gameState', 'moves': 'e2e4 c7c5 g1f3 b8c6 f1b5 g7g6 e1g1 f8g7 c2c3 g8f6 d1a4 e8g8 f1e1 e7e5 d2d3 d8c7 c1g5 h7h6 g5f6 g7f6 b5c4 a7a6 b1d2 a8b8 a4d1 f6g7 a2a4 b7b5 a4b5 a6b5 c4a2 c6e7 d2f1 g8h8 h2h4 f7f5 h4h5 g6g5 e4f5 e7f5 d1e2 d7d6 f3d2 c8b7 a2e6 c7b6 a1c1 b6c6 f1e3 f5e3 f2e3 d6d5 e6g4 c5c4 d3d4 b8e8 d2f3 e5d4 f3d4 g7d4 c3d4 h8g7 e1f1 b7c8 f1f8 e8f8 c1e1 c8g4 e2g4 b5b4 e1a1 f8f7 g4g3 c6c7 g3c7 f7c7 g2g4 c7f7 g1g2 b4b3 a1a4 f7f6 e3e4 f6f4 a4a7 g7f6 a7a6 f6f7 e4d5 f4g4 g2f3 g4g1 a6c6 g5g4 f3f4 g1c1 c6h6 c4c3 b2c3 g4g3 f4g3 b3b2 h6b6 b2b1q b6b1 c1b1 g3f4 b1c1 d5d6 c1f1 f4g5 f1f6 d6d7 f6d6 g5f5 d6d7 h5h6 d7c7 h6h7 c7c8 f5e4 f7g6 e4d5 g6h7 c3c4 h7g6 c4c5 g6f6 d5e4 f6e6 d4d5 e6f7 c5c6 c8g8 e4d4 f7e7 d4c5 g8g5 c6c7 e7d7 c7c8q d7c8 c5c6 g5g6 c6c5 c8c7 c5d4 c7d6 d4e4 g6g5 e4f4 g5e5 f4g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e4 d8g8 e4d4 g8b8 d4e3 b8h8 e3d4 h8g8 d4e4 g8b8 e4e3', 'wtime': 6470, 'btime': 319180, 'winc': 3000, 'binc': 3000, 'status': 'started'}
2023-08-31 08:40:29,711 __mp_main__ INFO 
2023-08-31 08:40:29,712 __mp_main__ INFO move: 88
2023-08-31 08:40:29,806 engine_wrapper INFO Got move b8d8 from syzygy (wdl: 2, dtz: 21) for game K9tOivpn
2023-08-31 08:40:29,808 chess.engine DEBUG <UciProtocol (pid=11474)>: << stop
2023-08-31 08:40:29,809 engine_wrapper INFO Evaluation: 99.0
2023-08-31 08:40:29,963 urllib3.connectionpool DEBUG https://lichess.org:443 "POST /api/bot/game/K9tOivpn/move/b8d8?offeringDraw=false HTTP/1.1" 200 11
2023-08-31 08:40:29,971 __mp_main__ DEBUG Game state: {'type': 'gameState', 'moves': 'e2e4 c7c5 g1f3 b8c6 f1b5 g7g6 e1g1 f8g7 c2c3 g8f6 d1a4 e8g8 f1e1 e7e5 d2d3 d8c7 c1g5 h7h6 g5f6 g7f6 b5c4 a7a6 b1d2 a8b8 a4d1 f6g7 a2a4 b7b5 a4b5 a6b5 c4a2 c6e7 d2f1 g8h8 h2h4 f7f5 h4h5 g6g5 e4f5 e7f5 d1e2 d7d6 f3d2 c8b7 a2e6 c7b6 a1c1 b6c6 f1e3 f5e3 f2e3 d6d5 e6g4 c5c4 d3d4 b8e8 d2f3 e5d4 f3d4 g7d4 c3d4 h8g7 e1f1 b7c8 f1f8 e8f8 c1e1 c8g4 e2g4 b5b4 e1a1 f8f7 g4g3 c6c7 g3c7 f7c7 g2g4 c7f7 g1g2 b4b3 a1a4 f7f6 e3e4 f6f4 a4a7 g7f6 a7a6 f6f7 e4d5 f4g4 g2f3 g4g1 a6c6 g5g4 f3f4 g1c1 c6h6 c4c3 b2c3 g4g3 f4g3 b3b2 h6b6 b2b1q b6b1 c1b1 g3f4 b1c1 d5d6 c1f1 f4g5 f1f6 d6d7 f6d6 g5f5 d6d7 h5h6 d7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6f6 d5e4 f6e6 d4d5 e6f7 c5c6 c8g8 e4d4 f7e7 d4c5 g8g5 c6c7 e7d7 c7c8q d7c8 c5c6 g5g6 c6c5 c8c7 c5d4 c7d6 d4e4 g6g5 e4f4 g5e5 f4g4 d6c5 d5d6 e5e8 d6d7 e8d8 g4f3 c5c6 f3e4 c6b7 e4e5 b7c6 e5e4 d8g8 e4d4 g8b8 d4e3 b8h8 e3d4 h8g8 d4e4 g8b8 e4e3 b8d8 e3e4', 'wtime': 6850, 'btime': 321920, 'winc': 3000, 'binc': 3000, 'status': 'started'}
2023-08-31 08:40:32,584 __mp_main__ INFO 
2023-08-31 08:40:32,584 __mp_main__ INFO move: 89
2023-08-31 08:40:32,591 __main__ DEBUG Event: {'type': 'gameFinish', 'game': {'fullId': 'K9tOivpn6FYp', 'gameId': 'K9tOivpn', 'fen': '3r4/3P4/2k5/8/4K3/8/8/8 b - - 20 89', 'color': 'black', 'lastMove': 'e3e4', 'source': 'friend', 'status': {'id': 34, 'name': 'draw'}, 'variant': {'key': 'standard', 'name': 'Standard'}, 'speed': 'rapid', 'perf': 'rapid', 'rated': True, 'hasMoved': True, 'opponent': {'id': 'pawn_git', 'username': 'BOT pawn_git', 'rating': 2573, 'ratingDiff': 4}, 'isMyTurn': False, 'secondsLeft': 322, 'ratingDiff': -4, 'compat': {'bot': True, 'board': True}, 'id': 'K9tOivpn'}}
2023-08-31 08:40:32,595 matchmaking INFO Next challenge will be created after 08:45:32 (27 challenges in last 24 hours)
2023-08-31 08:40:32,597 __main__ INFO +++ Process Freed. Count: 0. IDs: None
2023-08-31 08:40:32,674 engine_wrapper INFO Got move d8b8 from syzygy (wdl: 2, dtz: 23) for game K9tOivpn
2023-08-31 08:40:32,676 chess.engine DEBUG <UciProtocol (pid=11474)>: << stop
2023-08-31 08:40:32,676 engine_wrapper INFO Evaluation: 99.0
2023-08-31 08:40:32,830 urllib3.connectionpool DEBUG https://lichess.org:443 "POST /api/bot/game/K9tOivpn/move/d8b8?offeringDraw=false HTTP/1.1" 400 47
2023-08-31 08:40:32,831 backoff DEBUG Giving up api_post(...) after 1 tries (requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://lichess.org/api/bot/game/K9tOivpn/move/d8b8?offeringDraw=false)
2023-08-31 08:40:32,985 urllib3.connectionpool DEBUG https://lichess.org:443 "GET /api/account/playing HTTP/1.1" 200 17
2023-08-31 08:40:32,986 __mp_main__ DEBUG Game state: {'type': 'gameState', 'moves': 'e2e4 c7c5 g1f3 b8c6 f1b5 g7g6 e1g1 f8g7 c2c3 g8f6 d1a4 e8g8 f1e1 e7e5 d2d3 d8c7 c1g5 h7h6 g5f6 g7f6 b5c4 a7a6 b1d2 a8b8 a4d1 f6g7 a2a4 b7b5 a4b5 a6b5 c4a2 c6e7 d2f1 g8h8 h2h4 f7f5 h4h5 g6g5 e4f5 e7f5 d1e2 d7d6 f3d2 c8b7 a2e6 c7b6 a1c1 b6c6 f1e3 f5e3 f2e3 d6d5 e6g4 c5c4 d3d4 b8e8 d2f3 e5d4 f3d4 g7d4 c3d4 h8g7 e1f1 b7c8 f1f8 e8f8 c1e1 c8g4 e2g4 b5b4 e1a1 f8f7 g4g3 c6c7 g3c7 f7c7 g2g4 c7f7 g1g2 b4b3 a1a4 f7f6 e3e4 f6f4 a4a7 g7f6 a7a6 f6f7 e4d5 f4g4 g2f3 g4g1 a6c6 g5g4 f3f4 g1c1 c6h6 c4c3 b2c3 g4g3 f4g3 b3b2 h6b6 b2b1q b6b1 c1b1 g3f4 b1c1 d5d6 c1f1 f4g5 f1f6 d6d7 f6d6 g5f5 d6d7 h5h6 d7c7 h6h7 c7c8 f5e4 f7g6 e4d5 g6h7 c3c4 h7g6 c4c5 g6f6 d5e4 f6e6 d4d5 e6f7 c5c6 c8g8 e4d4 f7e7 d4c5 g8g5 c6c7 e7d7 c7c8q d7c8 c5c6 g5g6 c6c5 c8c7 c5d4 c7d6 d4e4 g6g5 e4f4 g5e5 f4g4 d6c5 d5d6 e5e8 d6d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8g8 e4d4 g8b8 d4e3 b8h8 e3d4 h8g8 d4e4 g8b8 e4e3 b8d8 e3e4
2023-08-31 08:40:32,993 __mp_main__ INFO Game ended in a draw.
2023-08-31 08:40:32,994 __mp_main__ INFO Game drawn by threefold repetition.
2023-08-31 08:40:32,994 conversation INFO *** https://lichess.org/K9tOivpn/black [player] ArasanX: Good game!
jdart1 commented 1 year ago

This could be an issue in python-chess. The correct way to do move filtering is to rank the moves (using dtz if possible, otherwise wdl), taking into account repetition status: see https://github.com/jdart1/arasan-chess/blob/master/src/syzygy.cpp. And then select only moves that are not less in rank than the highest-ranked move: see RootMoveGenerator::filter (https://github.com/jdart1/arasan-chess/blob/master/src/movegen.cpp).

MarkZH commented 1 year ago

Can you test the linked PR (#831) and confirm if this fixes the problem?

jdart1 commented 1 year ago

This is a rarely occurring problem in game play, so I can test it but may not succeed in validating the fix. I think this would be better validated through some kind of unit test.

AttackingOrDefending commented 1 year ago

It fixes it in this specific situation. For fen 1r6/3P4/2k5/8/8/4K3/8/8 b - - 18 88: Before:

(Move.from_uci('c6d6'), 2)  # Or some other move like b8d8 or b8h8

After:

(Move.from_uci('c6d7'), 2)