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

ChessChallenge.Chess.RepetitionTable crashes when game takes more then 256 plies #415

Closed Skoolin closed 11 months ago

Skoolin commented 11 months ago

If the game takes longer than 256 plies, it crashes.

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at ChessChallenge.Chess.RepetitionTable.Contains(UInt64 h) 

int[] startindices und int[] hashes are only of size 256.

proposal for a fix: hashes = new ulong[1024]; in ChessChallenge.Chess.RepetitionTable

Skoolin commented 11 months ago

We saw there is a bounds check in the Push method. count++; is not included inside the bounds check. if it where, it would not detect any repetitions after ply 256 has been reached but not crash.

SebLague commented 11 months ago

I've increased the size as proposed, thanks!