}
-/// Position::setTranspositionTable() is used by search functions to pass
-/// the pointer to the used TT so that do_move() will prefetch TT access.
-
-void Position::setTranspositionTable(TranspositionTable* tt) {
- TT = tt;
-}
-
-
/// Position::from_fen() initializes the position object with the given FEN
/// string. This function is not very robust - make sure that input FENs are
/// correct (this is assumed to be the responsibility of the GUI).
// case of non-reversible moves is taken care of later.
st->rule50++;
+ // Update side to move
+ st->key ^= zobSideToMove;
+
if (move_is_castle(m))
do_castle_move(m);
else if (move_is_promotion(m))
st->capture = type_of_piece_on(to);
if (st->capture)
- do_capture_move(st->capture, them, to);
+ do_capture_move(st->capture, them, to);
// Update hash key
st->key ^= zobrist[us][pt][from] ^ zobrist[us][pt][to];
- st->key ^= zobSideToMove;
// Reset en passant square
if (st->epSquare != SQ_NONE)
st->key ^= zobCastle[st->castleRights];
}
- bool checkEpSquare = (pt == PAWN && abs(int(to) - int(from)) == 16);
-
// Prefetch TT access as soon as we know key is updated
- if (!checkEpSquare && TT)
- TT->prefetch(st->key);
+ TT.prefetch(st->key);
// Move the piece
Bitboard move_bb = make_move_bb(from, to);
st->pawnKey ^= zobrist[us][PAWN][from] ^ zobrist[us][PAWN][to];
// Set en passant square, only if moved pawn can be captured
- if (checkEpSquare)
+ if (abs(int(to) - int(from)) == 16)
{
if ( (us == WHITE && (pawn_attacks(WHITE, from + DELTA_N) & pawns(BLACK)))
|| (us == BLACK && (pawn_attacks(BLACK, from + DELTA_S) & pawns(WHITE))))
}
}
- // Prefetch only here in the few cases we needed zobEp[] to update the key
- if (checkEpSquare && TT)
- TT->prefetch(st->key);
-
// Update incremental scores
st->mgValue += pst_delta<MidGame>(piece, from, to);
st->egValue += pst_delta<EndGame>(piece, from, to);
// Update checkers BB
st->checkersBB = attacks_to(king_square(them), us);
-
- st->key ^= zobSideToMove;
}
// Update checkers BB
st->checkersBB = attacks_to(king_square(them), us);
-
- st->key ^= zobSideToMove;
}
// Update checkers BB
st->checkersBB = attacks_to(king_square(them), us);
-
- st->key ^= zobSideToMove;
}
st->key ^= zobEp[st->epSquare];
st->key ^= zobSideToMove;
- TT->prefetch(st->key);
+ TT.prefetch(st->key);
sideToMove = opposite_color(sideToMove);
st->epSquare = SQ_NONE;
st->rule50++;
initialKFile = FILE_E;
initialKRFile = FILE_H;
initialQRFile = FILE_A;
- TT = NULL;
}