SebLague / Chess-Challenge

Create your own tiny chess bot!
https://www.youtube.com/watch?v=Ne40a5LkK6A
MIT License
1.77k stars 1.06k forks source link

board.MakeMove is throwing an exception on moves provided by board.GetLegalMoves() #375

Open b4ux1t3 opened 1 year ago

b4ux1t3 commented 1 year ago

I ran into this when I was implementing some simple heuristics around queen losses.

I have a branch here that runs into this issue every time it runs:

https://github.com/b4ux1t3/Seb-Lague-Chess-Challenge/tree/bug-in-library-queen-check

To reproduce, just run this branch and you should see the following exception: Screenshot 2023-07-28 at 10 02 34 AM

I dug through it a little and it appears to originate from line 60 of my code, where I call board.MakeMove, but only when coming from the method MoveWouldLoseQueen. I use it all over the place otherwise with no issue.

The thing is, I'm only ever passing legal moves provided by the library.