mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
Index en-passant zobrist keys by file
Instead of by square. This is a more conventional approach, as reported also in: http://chessprogramming.wikispaces.com/Zobrist+Hashing We shrink zobEp[] from 64 to 8 keys at the cost of an extra 'and 7' at runtime to get the file out of the ep square. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -36,7 +36,7 @@ using std::cout;
|
||||
using std::endl;
|
||||
|
||||
Key Position::zobrist[2][8][64];
|
||||
Key Position::zobEp[64];
|
||||
Key Position::zobEp[8];
|
||||
Key Position::zobCastle[16];
|
||||
Key Position::zobSideToMove;
|
||||
Key Position::zobExclusion;
|
||||
@@ -835,7 +835,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||
// Reset en passant square
|
||||
if (st->epSquare != SQ_NONE)
|
||||
{
|
||||
k ^= zobEp[st->epSquare];
|
||||
k ^= zobEp[file_of(st->epSquare)];
|
||||
st->epSquare = SQ_NONE;
|
||||
}
|
||||
|
||||
@@ -873,7 +873,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||
&& (attacks_from<PAWN>(from + pawn_push(us), us) & pieces(PAWN, them)))
|
||||
{
|
||||
st->epSquare = Square((from + to) / 2);
|
||||
k ^= zobEp[st->epSquare];
|
||||
k ^= zobEp[file_of(st->epSquare)];
|
||||
}
|
||||
|
||||
if (is_promotion(m))
|
||||
@@ -1146,7 +1146,7 @@ void Position::do_castle_move(Move m) {
|
||||
// Clear en passant square
|
||||
if (st->epSquare != SQ_NONE)
|
||||
{
|
||||
st->key ^= zobEp[st->epSquare];
|
||||
st->key ^= zobEp[file_of(st->epSquare)];
|
||||
st->epSquare = SQ_NONE;
|
||||
}
|
||||
|
||||
@@ -1195,7 +1195,7 @@ void Position::do_null_move(StateInfo& backupSt) {
|
||||
if (Do)
|
||||
{
|
||||
if (st->epSquare != SQ_NONE)
|
||||
st->key ^= zobEp[st->epSquare];
|
||||
st->key ^= zobEp[file_of(st->epSquare)];
|
||||
|
||||
st->key ^= zobSideToMove;
|
||||
prefetch((char*)TT.first_entry(st->key));
|
||||
@@ -1396,7 +1396,7 @@ Key Position::compute_key() const {
|
||||
result ^= zobrist[color_of(piece_on(s))][type_of(piece_on(s))][s];
|
||||
|
||||
if (ep_square() != SQ_NONE)
|
||||
result ^= zobEp[ep_square()];
|
||||
result ^= zobEp[file_of(ep_square())];
|
||||
|
||||
if (sideToMove == BLACK)
|
||||
result ^= zobSideToMove;
|
||||
@@ -1542,8 +1542,8 @@ void Position::init() {
|
||||
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
||||
zobrist[c][pt][s] = rk.rand<Key>();
|
||||
|
||||
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
||||
zobEp[s] = rk.rand<Key>();
|
||||
for (File f = FILE_A; f <= FILE_H; f++)
|
||||
zobEp[f] = rk.rand<Key>();
|
||||
|
||||
for (int cr = CASTLES_NONE; cr <= ALL_CASTLES; cr++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user