From 3d076a0c50cae378c463fdd2a65a250eda55edab Mon Sep 17 00:00:00 2001 From: protonspring Date: Thu, 16 May 2019 06:11:00 -0600 Subject: [PATCH] Consolidate some code in set_state. (#2151) Non functional change. --- src/position.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 901e91a7..b8d7b106 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -383,6 +383,12 @@ void Position::set_state(StateInfo* si) const { Square s = pop_lsb(&b); Piece pc = piece_on(s); si->key ^= Zobrist::psq[pc][s]; + + if (type_of(pc) == PAWN) + si->pawnKey ^= Zobrist::psq[pc][s]; + + else if (type_of(pc) != PAWN && type_of(pc) != KING) + si->nonPawnMaterial[color_of(pc)] += PieceValue[MG][pc]; } if (si->epSquare != SQ_NONE) @@ -393,20 +399,9 @@ void Position::set_state(StateInfo* si) const { si->key ^= Zobrist::castling[si->castlingRights]; - for (Bitboard b = pieces(PAWN); b; ) - { - Square s = pop_lsb(&b); - si->pawnKey ^= Zobrist::psq[piece_on(s)][s]; - } - for (Piece pc : Pieces) - { - if (type_of(pc) != PAWN && type_of(pc) != KING) - si->nonPawnMaterial[color_of(pc)] += pieceCount[pc] * PieceValue[MG][pc]; - for (int cnt = 0; cnt < pieceCount[pc]; ++cnt) si->materialKey ^= Zobrist::psq[pc][cnt]; - } } -- 2.39.2