SebLague / Chess-Challenge

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

[BUG] board.GetLegalMoves(true) makes IsStalemate behavior wrong #418

Closed EikeSchwass closed 11 months ago

EikeSchwass commented 11 months ago

If you call the board.GetLegalMoves(true) method and it returns 0 moves (although non captures would be available), board.HasZeroLegalMoves() uses the cached GetLegalMoves(true) response and returns true.

SebLague commented 11 months ago

Should be fixed now, thank you! (I assume you were using the NonAlloc version of GetLegalMoves because I couldn't find an error with the regular version?)

EikeSchwass commented 11 months ago

Should be fixed now, thank you! (I assume you were using the NonAlloc version of GetLegalMoves because I couldn't find an error with the regular version?)

Yes, sorry! I assumed the error would be the same in both GetLegalMoves and GetLegalMovesNonAlloc, should have been more rigorous in my bug report. Thanks for fixing it :)