Add bounds check to repetition table (just in case)
This commit is contained in:
parent
6c9b67aa10
commit
3c5876a8ba
1 changed files with 7 additions and 3 deletions
|
@ -12,7 +12,7 @@ namespace ChessChallenge.Chess
|
|||
public RepetitionTable()
|
||||
{
|
||||
hashes = new ulong[256];
|
||||
startIndices = new int[hashes.Length];
|
||||
startIndices = new int[hashes.Length + 1];
|
||||
}
|
||||
|
||||
public void Init(Board board)
|
||||
|
@ -30,10 +30,14 @@ namespace ChessChallenge.Chess
|
|||
|
||||
|
||||
public void Push(ulong hash, bool reset)
|
||||
{
|
||||
// Check bounds just in case
|
||||
if (count < hashes.Length)
|
||||
{
|
||||
hashes[count] = hash;
|
||||
startIndices[count + 1] = reset ? count : startIndices[count];
|
||||
}
|
||||
count++;
|
||||
startIndices[count] = reset ? count - 1 : startIndices[count - 1];
|
||||
}
|
||||
|
||||
public void TryPop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue