encapsulated positionIndex and moved isdraw to board class
This commit is contained in:
1 parent
dd6f0b94f5
commit
aa0d34eb8e
7 files changed
+35
-41
No files matched your search
@@ -28,6 +28,8 @@ void Board::Reset() {
|
||||
|
||||
currentMoveIndex = 0;
|
||||
|
||||
positionIndex = 0;
|
||||
|
||||
hashKey = 0ULL;
|
||||
}
|
||||
|
||||
@@ -441,4 +443,29 @@ void Board::ResetAccPair() {
|
||||
|
||||
blackPieces.PopBit(square);
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsThreefold(Board& board) {
|
||||
for (int i = 0; i < board.positionIndex; i++) {
|
||||
if (positionHistory[i] == board.hashKey) {
|
||||
// repetition found
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// no repetition
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsFifty(Board& board) {
|
||||
return (board.halfMoves >= 100);
|
||||
}
|
||||
|
||||
static bool IsInsuffMat(Board& board) {
|
||||
return (board.occupied.PopCount() <= 3
|
||||
&& !(board.pieces[Pawn] | board.pieces[Queen] | board.pieces[Rook]));
|
||||
}
|
||||
|
||||
bool Board::IsDraw() {
|
||||
return IsFifty(*this) || IsInsuffMat(*this) || IsThreefold(*this);
|
||||
}
|
||||
Reference in new issue
Block a user