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()
|
public RepetitionTable()
|
||||||
{
|
{
|
||||||
hashes = new ulong[256];
|
hashes = new ulong[256];
|
||||||
startIndices = new int[hashes.Length];
|
startIndices = new int[hashes.Length + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(Board board)
|
public void Init(Board board)
|
||||||
|
@ -31,9 +31,13 @@ namespace ChessChallenge.Chess
|
||||||
|
|
||||||
public void Push(ulong hash, bool reset)
|
public void Push(ulong hash, bool reset)
|
||||||
{
|
{
|
||||||
hashes[count] = hash;
|
// Check bounds just in case
|
||||||
|
if (count < hashes.Length)
|
||||||
|
{
|
||||||
|
hashes[count] = hash;
|
||||||
|
startIndices[count + 1] = reset ? count : startIndices[count];
|
||||||
|
}
|
||||||
count++;
|
count++;
|
||||||
startIndices[count] = reset ? count - 1 : startIndices[count - 1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TryPop()
|
public void TryPop()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue