diff --git a/source/board.cpp b/source/board.cpp index 0573eea..59be5b7 100644 --- a/source/board.cpp +++ b/source/board.cpp @@ -522,32 +522,3 @@ void Board::ResetAccPair() { blackPieces.PopBit(square); } } - -Bitboard Board::AttacksTo(int square, Bitboard occupancy) { - Bitboard attacks; - - // Pawn attacks - - // Opponent attacks - attacks |= (MOVEGEN::pawnAttacks[sideToMove][square] & colors[!sideToMove] & pieces[Pawn]); - - // Own piece attacks - attacks |= (MOVEGEN::pawnAttacks[!sideToMove][square] & colors[sideToMove] & pieces[Pawn]); - - // Knight - attacks |= (MOVEGEN::knightAttacks[square] & pieces[Knight]); - - // King - attacks |= (MOVEGEN::kingAttacks[square] & pieces[King]); - - Bitboard bishopAttacks = MOVEGEN::getBishopAttack(square, occupancy); - Bitboard rookAttacks = MOVEGEN::getRookAttack(square, occupancy); - - // Rook or queen - attacks |= (rookAttacks & (pieces[Rook] | pieces[Queen])); - - // Bishop or queen - attacks |= (bishopAttacks & (pieces[Bishop] | pieces[Queen])); - - return attacks; -} diff --git a/source/board.h b/source/board.h index 8a3a26a..137ddcd 100644 --- a/source/board.h +++ b/source/board.h @@ -66,6 +66,4 @@ public: bool MakeMove(Move move); bool InPossibleZug(); - - Bitboard AttacksTo(int square, Bitboard occupancy); }; diff --git a/source/search.cpp b/source/search.cpp index 336a629..d78b0c5 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -125,79 +125,6 @@ static int GetReductions(Board &board, Move &move, int depth, int moveSeen, int return reduction; } -static int SEE(Board& board, Move& move, int threshold) { - int from = move.MoveFrom(); - int to = move.MoveTo(); - int flags = move.GetFlags(); - - int nextVictim = -1; - - // Next victim is moved piece or promo piece - if (move.IsPromo()) { - if (move.IsCapture()) { - nextVictim = move.GetFlags() - 9; - } else { - nextVictim = move.GetFlags() - 5; - } - } else { - nextVictim = board.GetPieceType(from); - } - - int balance = MoveEstimatedValue(board, move) - threshold; - - if (balance < 0) return 0; - - balance -= SEEPieceValues[nextVictim]; - - if (balance >= 0) return 1; - - Bitboard bishops = board.pieces[Bishop] | board.pieces[Queen]; - Bitboard rooks = board.pieces[Rook] | board.pieces[Queen]; - - Bitboard occupied = board.occupied; - occupied = (occupied ^ Bitboard((1ULL << from))) | Bitboard((1ULL << to)); - - if (flags == epCapture) - occupied ^= Bitboard(1ULL << board.enPassantTarget); - - Bitboard attackers = board.AttacksTo(to, occupied) & occupied; - - bool color = !board.sideToMove; - - while (true) { - Bitboard myAttackers = attackers & board.colors[color]; - if (!myAttackers) break; - - for (nextVictim = Pawn; nextVictim <= Queen; nextVictim++) { - if (myAttackers & board.pieces[nextVictim]) - break; - } - - occupied ^= Bitboard(1ULL << Bitboard(myAttackers & board.pieces[nextVictim]).getLS1BIndex()); - - if (nextVictim == Pawn || nextVictim == Bishop || nextVictim == Queen) - attackers |= MOVEGEN::getBishopAttack(to, occupied) & bishops; - - if (nextVictim == Rook || nextVictim == Queen) - attackers |= MOVEGEN::getRookAttack(to, occupied) & rooks; - - attackers &= occupied; - - color = !color; - - balance = -balance - 1 - SEEPieceValues[nextVictim]; - - if (balance >= 0) { - if (nextVictim == King && (attackers & board.colors[color])) - color = !color; - - break; - } - } - - return board.sideToMove != color; -} - template static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, SearchContext& ctx) { if constexpr (mode != nodesMode) { @@ -251,10 +178,6 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear Board copy = board; int isLegal = copy.MakeMove(board.moveList[i]); if (!isLegal) continue; - - if (!SEE(board, board.moveList[i], 0)) - continue; - if (copy.positionIndex >= ctx.positionHistory.size()) { ctx.positionHistory.resize(copy.positionIndex + 100); } @@ -599,27 +522,6 @@ SearchResults SearchPosition(Board &board, SearchParams params, SearchContext& c return results; } -int MoveEstimatedValue(Board& board, Move& move) { - int value = SEEPieceValues[board.GetPieceType(move.MoveTo())]; - - if (move.IsPromo()) { - int promoPiece = -1; - if (move.IsCapture()) { - promoPiece = move.GetFlags() - 9; - } else { - promoPiece = move.GetFlags() - 5; - } - - value += SEEPieceValues[promoPiece] - SEEPieceValues[Pawn]; - } else if (move.GetFlags() == epCapture) { - value = SEEPieceValues[Pawn]; - } else if (move.GetFlags() == queenCastle || move.GetFlags() == kingCastle) { - value = 0; - } - - return value; -} - template SearchResults PVS(Board&, int, int, int, int, SearchContext& ctx); template SearchResults PVS(Board&, int, int, int, int, SearchContext& ctx); template SearchResults PVS(Board&, int, int, int, int, SearchContext& ctx); diff --git a/source/search.h b/source/search.h index 592ecfb..d56ca14 100644 --- a/source/search.h +++ b/source/search.h @@ -26,11 +26,6 @@ constexpr int inf = 100000; inline int lmrTable[MAX_DEPTH+1][MAX_MOVES]; -static const int SEEPieceValues[] = { - 103, 422, 437, 694, - 1313, 0, 0, 0, -}; - void InitLMRTable(); class History { @@ -147,6 +142,4 @@ constexpr int moveScoreTable[6][6] = { }; void ListScores(Board &board, SearchContext& ctx); - -int MoveEstimatedValue(Board& board, Move& move); }