sync_cout;
if (move)
- {
- Position p(*this);
- cout << "\nMove is: " << (sideToMove == BLACK ? ".." : "") << move_to_san(p, move);
- }
+ cout << "\nMove is: " << (sideToMove == BLACK ? ".." : "")
+ << move_to_san(*const_cast<Position*>(this), move);
for (Square sq = SQ_A1; sq <= SQ_H8; sq++)
if (piece_on(sq) != NO_PIECE)
for (int i = 0; i < 8; i++)
for (int j = 0; j < 16; j++)
pieceList[0][i][j] = pieceList[1][i][j] = SQ_NONE;
-
- for (Square sq = SQ_A1; sq <= SQ_H8; sq++)
- board[sq] = NO_PIECE;
}
/// Position::is_draw() tests whether the position is drawn by material,
/// repetition, or the 50 moves rule. It does not detect stalemates, this
/// must be done by the search.
-template<bool SkipRepetition>
+template<bool SkipRepetition, bool SkipThreeFoldCheck>
bool Position::is_draw() const {
// Draw by material?
// Draw by repetition?
if (!SkipRepetition)
{
- int i = 4, e = std::min(st->rule50, st->pliesFromNull);
+ int i = 4, e = std::min(st->rule50, st->pliesFromNull), rep_count=0;
if (i <= e)
{
stp = stp->previous->previous;
if (stp->key == st->key)
- return true;
+ {
+ if(SkipThreeFoldCheck) return true;
+ else if(++rep_count>=2) return true;
+ }
i +=2;
}
// Explicit template instantiations
-template bool Position::is_draw<false>() const;
-template bool Position::is_draw<true>() const;
+template bool Position::is_draw<false,true>() const;
+template bool Position::is_draw<true,true>() const;
+template bool Position::is_draw<false,false>() const;
/// Position::flip() flips position with the white and black sides reversed. This