#include <fstream>
#include <iostream>
#include <sstream>
+#include <algorithm>
#include "bitcount.h"
#include "movegen.h"
checkSq[BISHOP] = pos.attacks_from<BISHOP>(ksq);
checkSq[ROOK] = pos.attacks_from<ROOK>(ksq);
checkSq[QUEEN] = checkSq[BISHOP] | checkSq[ROOK];
- checkSq[KING] = EmptyBoardBB;
+ checkSq[KING] = 0;
}
/// or the FEN string, we want the new born Position object do not depend
/// on any external data so we detach state pointer from the source one.
-Position::Position(const Position& pos, int th) {
+void Position::copy(const Position& pos, int th) {
memcpy(this, &pos, sizeof(Position));
+ startState = *st;
+ st = &startState;
threadID = th;
nodes = 0;
// Convert from fullmove starting from 1 to ply starting from 0,
// handle also common incorrect FEN with fullmove = 0.
- startPosPly = Max(2 * (startPosPly - 1), 0) + int(sideToMove == BLACK);
+ startPosPly = std::max(2 * (startPosPly - 1), 0) + int(sideToMove == BLACK);
st->key = compute_key();
st->pawnKey = compute_pawn_key();
st->key = key;
// Update checkers bitboard, piece must be already moved
- st->checkersBB = EmptyBoardBB;
+ st->checkersBB = 0;
if (moveIsCheck)
{
// Having built the swap list, we negamax through it to find the best
// achievable score from the point of view of the side to move.
while (--slIndex)
- swapList[slIndex-1] = Min(-swapList[slIndex], swapList[slIndex-1]);
+ swapList[slIndex-1] = std::min(-swapList[slIndex], swapList[slIndex-1]);
return swapList[0];
}
// Draw by repetition?
if (!SkipRepetition)
{
- int i = 4, e = Min(st->rule50, st->pliesFromNull);
+ int i = 4, e = std::min(st->rule50, st->pliesFromNull);
if (i <= e)
{
if (debugBitboards)
{
// The intersection of the white and black pieces must be empty
- if ((pieces(WHITE) & pieces(BLACK)) != EmptyBoardBB)
+ if (!(pieces(WHITE) & pieces(BLACK)))
return false;
// The union of the white and black pieces must be equal to all