diff --git a/source/search.cpp b/source/search.cpp index f0b9918..2f55061 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -132,12 +132,12 @@ static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int return std::clamp(reduction, -1, depth - 1); } -static int SEE(Board& board, Move& move, int threshold) { +static bool SEE(Board& board, Move& move, int threshold) { int from = move.MoveFrom(); int to = move.MoveTo(); int flags = move.GetFlags(); - int nextVictim = -1; + int nextVictim = board.GetPieceType(from); // Next victim is moved piece or promo piece if (move.IsPromo()) { @@ -146,8 +146,6 @@ static int SEE(Board& board, Move& move, int threshold) { } else { nextVictim = move.GetFlags() - 5; } - } else { - nextVictim = board.GetPieceType(from); } int balance = MoveEstimatedValue(board, move) - threshold; @@ -162,10 +160,11 @@ static int SEE(Board& board, Move& move, int threshold) { Bitboard rooks = board.pieces[Rook] | board.pieces[Queen]; Bitboard occupied = board.occupied; - occupied = (occupied ^ Bitboard((1ULL << from))) | Bitboard((1ULL << to)); + occupied.PopBit(from); + occupied.SetBit(to); if (flags == epCapture) - occupied ^= Bitboard(1ULL << board.enPassantTarget); + occupied.SetBit(board.enPassantTarget); Bitboard attackers = board.AttacksTo(to, occupied) & occupied; @@ -180,7 +179,7 @@ static int SEE(Board& board, Move& move, int threshold) { break; } - occupied ^= Bitboard(1ULL << Bitboard(myAttackers & board.pieces[nextVictim]).getLS1BIndex()); + occupied.PopBit(Bitboard(myAttackers & board.pieces[nextVictim]).getLS1BIndex()); if (nextVictim == Pawn || nextVictim == Bishop || nextVictim == Queen) attackers |= MOVEGEN::getBishopAttack(to, occupied) & bishops; diff --git a/source/search.h b/source/search.h index cb493ac..08e5db9 100644 --- a/source/search.h +++ b/source/search.h @@ -26,9 +26,8 @@ constexpr int inf = 100000; inline int lmrTable[MAX_DEPTH+1][MAX_MOVES]; -static const int SEEPieceValues[] = { - 100, 300, 350, 500, - 900, 0, 0, 0, +constexpr std::array SEEPieceValues = { + 100, 300, 350, 500, 900, 0 }; void InitLMRTable();