From 28ce0bc64cf1528ea8ce382b55ac232c937fb7e8 Mon Sep 17 00:00:00 2001 From: rektdie Date: Mon, 24 Mar 2025 00:33:21 +0100 Subject: [PATCH] generating pawn moves --- source/board.cpp | 7 +- source/movegen.cpp | 590 +-------------------------------------------- source/movegen.h | 31 ++- source/movegen.tpp | 91 +++++++ source/perft.cpp | 4 +- source/search.cpp | 4 +- source/uci.cpp | 3 +- source/utils.cpp | 2 +- 8 files changed, 134 insertions(+), 598 deletions(-) create mode 100644 source/movegen.tpp diff --git a/source/board.cpp b/source/board.cpp index 2625a5f..2a9319e 100644 --- a/source/board.cpp +++ b/source/board.cpp @@ -65,8 +65,7 @@ void Board::SetByFen(std::string_view fen) { occupied = colors[White] | colors[Black]; hashKey = UTILS::GetHashKey(*this); - MOVEGEN::GenerateMoves(*this); - MOVEGEN::GenAttackMaps(*this); + MOVEGEN::GenerateMoves(*this); } void Board::PrintBoard() { @@ -339,9 +338,7 @@ void Board::MakeMove(Move move) { } enPassantTarget = newEpTarget; - - MOVEGEN::GenAttackMaps(*this); - + positionIndex++; positionHistory[positionIndex] = hashKey; } diff --git a/source/movegen.cpp b/source/movegen.cpp index 82b0387..3ee4521 100644 --- a/source/movegen.cpp +++ b/source/movegen.cpp @@ -2,11 +2,6 @@ namespace MOVEGEN { -static Bitboard pawnAttacks[2][64]; -static Bitboard knightAttacks[64]; -static Bitboard kingAttacks[64]; - - static Bitboard bishopMasks[64]; static Bitboard rookMasks[64]; @@ -240,7 +235,7 @@ void initSliderAttacks() { } } -static Bitboard getBishopAttack(int square, U64 occupancy) { +Bitboard getBishopAttack(int square, U64 occupancy) { occupancy &= bishopMasks[square]; occupancy *= bishopMagicNumbers[square]; occupancy >>= (64 - bishopRelevantBits[square]); @@ -248,7 +243,7 @@ static Bitboard getBishopAttack(int square, U64 occupancy) { return bishopAttacks[square][occupancy]; } -static Bitboard getRookAttack(int square, U64 occupancy) { +Bitboard getRookAttack(int square, U64 occupancy) { occupancy &= rookMasks[square]; occupancy *= rookMagicNumbers[square]; occupancy >>= (64 - rookRelevantBits[square]); @@ -256,7 +251,7 @@ static Bitboard getRookAttack(int square, U64 occupancy) { return rookAttacks[square][occupancy]; } -static Bitboard getQueenAttack(int square, U64 occupancy) { +Bitboard getQueenAttack(int square, U64 occupancy) { U64 bishopOccupancy = occupancy; U64 rookOccupancy = occupancy; @@ -271,7 +266,7 @@ static Bitboard getQueenAttack(int square, U64 occupancy) { return rookAttacks[square][rookOccupancy] | bishopAttacks[square][bishopOccupancy]; } -static Bitboard getPieceAttacks(int square, int piece, int color, U64 occupancy) { +Bitboard getPieceAttacks(int square, int piece, int color, U64 occupancy) { if (piece == Pawn) { return pawnAttacks[color][square]; } else if (piece == Knight) { @@ -287,7 +282,7 @@ static Bitboard getPieceAttacks(int square, int piece, int color, U64 occupancy) } } -static Bitboard getPawnPushes(int square, bool color, Bitboard &occupancy) { +Bitboard getPawnPushes(int square, bool color, Bitboard &occupancy) { Bitboard pushes; int direction = color ? south : north; @@ -429,579 +424,4 @@ static bool IsPinned(Board &board, int square) { return false; } - -static bool IsLegalEnPassant(Board &board, int square) { - Bitboard kingSquare = board.colors[board.sideToMove] & board.pieces[King]; - int pushDirection = board.sideToMove ? south : north; - Bitboard newOccupancy = board.occupied; - newOccupancy.PopBit(square); - newOccupancy.PopBit(board.enPassantTarget - pushDirection); - - // Looking for horizontal checks - int directionToKing = GetDirection(square, kingSquare.getLS1BIndex()); - - // Either east or west - if (abs(directionToKing) == 1) { - int currentSq = kingSquare.getLS1BIndex() - directionToKing; - - Bitboard endingFile = directionToKing > 0 ? files[H] : files[A]; - - while (!endingFile.IsSet(currentSq)) { - if (newOccupancy.IsSet(currentSq)) { - int squareColor = board.GetPieceColor(currentSq); - int squarePiece = board.GetPieceType(currentSq); - - if (squareColor != board.sideToMove) { - if (squarePiece == Rook || squarePiece == Queen) { - return false; - } - } - break; - } - currentSq -= directionToKing; - } - } - - return true; -} - -static void GenPawnMoves(Board &board, bool color) { - Bitboard pawns = board.colors[color] & board.pieces[Pawn]; - - while (pawns) { - int square = pawns.getLS1BIndex(); - - Bitboard pushes = getPawnPushes(square, color, board.occupied); - Bitboard captures = pawnAttacks[color][square]; - - Bitboard lastRank = color ? ranks[r_1] : ranks[r_8]; - - if (IsPinned(board, square)) { - int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); - int directionToKing = GetDirection(square, kingSquare); - - Bitboard pinningRay = GetPinningRay(board, square, -directionToKing); - pushes &= pinningRay; - captures &= pinningRay; - - // Checking for en passant - if (board.enPassantTarget != noEPTarget) { - if (captures.IsSet(board.enPassantTarget)) { - if (IsLegalEnPassant(board, square)) { - board.AddMove(Move(square, board.enPassantTarget, epCapture)); - } - } - } - - // Removing own pieces from capture mask - captures &= board.colors[!color]; - - while (pushes) { - int pushSquare = pushes.getLS1BIndex(); - - if (abs(square - pushSquare) == 16) { - board.AddMove(Move(square, pushSquare, doublePawnPush)); - } else { - board.AddMove(Move(square, pushSquare, quiet)); - } - - pushes.PopBit(pushSquare); - } - - while (captures) { - int targetSquare = captures.getLS1BIndex(); - - // Checking for promotion - if (lastRank.IsSet(targetSquare)) { - board.AddMove(Move(square, targetSquare, knightPromoCapture)); - board.AddMove(Move(square, targetSquare, bishopPromoCapture)); - board.AddMove(Move(square, targetSquare, rookPromoCapture)); - board.AddMove(Move(square, targetSquare, queenPromoCapture)); - } else { - board.AddMove(Move(square, targetSquare, capture)); - } - - captures.PopBit(targetSquare); - } - - pawns.PopBit(square); - continue; - } - - // Checking for en passant - if (board.enPassantTarget != noEPTarget) { - if (captures.IsSet(board.enPassantTarget)) { - // Checking if the move gives discovered check to own king - if (IsLegalEnPassant(board, square)) { - board.AddMove(Move(square, board.enPassantTarget, epCapture)); - } - } - } - - // Removing own pieces from capture mask - captures &= board.colors[!color]; - - while (pushes) { - int pushSquare = pushes.getLS1BIndex(); - - // Checking for promotion - if (lastRank.IsSet(pushSquare)) { - board.AddMove(Move(square, pushSquare, knightPromotion)); - board.AddMove(Move(square, pushSquare, bishopPromotion)); - board.AddMove(Move(square, pushSquare, rookPromotion)); - board.AddMove(Move(square, pushSquare, queenPromotion)); - } else { - if (abs(square - pushSquare) == 16) { - board.AddMove(Move(square, pushSquare, doublePawnPush)); - } else { - board.AddMove(Move(square, pushSquare, quiet)); - } - } - - pushes.PopBit(pushSquare); - } - - while (captures) { - int targetSquare = captures.getLS1BIndex(); - - // Checking for promotion - if (lastRank.IsSet(targetSquare)) { - board.AddMove(Move(square, targetSquare, knightPromoCapture)); - board.AddMove(Move(square, targetSquare, bishopPromoCapture)); - board.AddMove(Move(square, targetSquare, rookPromoCapture)); - board.AddMove(Move(square, targetSquare, queenPromoCapture)); - } else { - board.AddMove(Move(square, targetSquare, capture)); - } - - captures.PopBit(targetSquare); - } - - pawns.PopBit(square); - } -} - -static void GenKnightMoves(Board &board, bool color) { - Bitboard knights = board.colors[color] & board.pieces[Knight]; - - while (knights) { - int square = knights.getLS1BIndex(); - - if (IsPinned(board, square)) { - knights.PopBit(square); - continue; - } - - Bitboard moves = knightAttacks[square] & ~board.colors[color]; - Bitboard captures = moves & board.colors[!color]; - moves &= ~captures; - - while (moves) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - knights.PopBit(square); - } -} - -static void GenRookMoves(Board &board, bool color) { - Bitboard rooks = board.colors[color] & board.pieces[Rook]; - - while (rooks) { - int square = rooks.getLS1BIndex(); - - Bitboard moves = getRookAttack(square, board.occupied) & ~board.colors[color]; - Bitboard captures = moves & board.colors[!color]; - moves &= ~captures; - - if (IsPinned(board, square)) { - int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); - int directionToKing = GetDirection(square, kingSquare); - - Bitboard pinningRay = GetPinningRay(board, square, -directionToKing); - - moves &= pinningRay; - captures &= pinningRay; - - while (moves) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - rooks.PopBit(square); - continue; - } - - - while (moves) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - rooks.PopBit(square); - } -} - -static void GenBishopMoves(Board &board, bool color) { - Bitboard bishops = board.colors[color] & board.pieces[Bishop]; - - while (bishops) { - int square = bishops.getLS1BIndex(); - - Bitboard moves = getBishopAttack(square, board.occupied) & ~board.colors[color]; - Bitboard captures = moves & board.colors[!color]; - moves &= ~captures; - - if (IsPinned(board, square)) { - int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); - int directionToKing = GetDirection(square, kingSquare); - - Bitboard pinningRay = GetPinningRay(board, square, -directionToKing); - - moves &= pinningRay; - captures &= pinningRay; - - while (moves) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - bishops.PopBit(square); - continue; - } - - - while (moves) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - bishops.PopBit(square); - } -} - -static void GenQueenMoves(Board &board, bool color) { - Bitboard queens = board.colors[color] & board.pieces[Queen]; - - while (queens) { - int square = queens.getLS1BIndex(); - - Bitboard moves = getQueenAttack(square, board.occupied) & ~board.colors[color]; - Bitboard captures = moves & board.colors[!color]; - moves &= ~captures; - - if (IsPinned(board, square)) { - int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); - int directionToKing = GetDirection(square, kingSquare); - - Bitboard pinningRay = GetPinningRay(board, square, -directionToKing); - - moves &= pinningRay; - captures &= pinningRay; - - while (moves) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - queens.PopBit(square); - continue; - } - - - while (moves) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - queens.PopBit(square); - } -} - -static void GenKingMoves(Board &board, bool color, bool isInCheck) { - int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); - - Bitboard moves = (kingAttacks[kingSquare] & ~board.GetAttackMaps(!color)) & ~board.colors[color]; - Bitboard captures = moves & board.colors[!color]; - moves &= ~board.colors[!color]; - - while (moves) { - int square = moves.getLS1BIndex(); - - board.AddMove(Move(kingSquare, square, quiet)); - - moves.PopBit(square); - } - - while (captures) { - int square = captures.getLS1BIndex(); - - Move move(kingSquare, square, capture); - board.AddMove(move); - - captures.PopBit(square); - } - - // Generating castles - int kingRight = color ? blackKingRight : whiteKingRight; - int queenRight = color ? blackQueenRight : whiteQueenRight; - - if (board.castlingRights & queenRight) { - U64 QueenSide = color ? 0x1f00000000000000 : 0x1f; - U64 mask = color ? 0x1c00000000000000 : 0x1c; - int targetSquare = color ? c8 : c1; - if ((Bitboard(QueenSide) & board.occupied).PopCount() == 2 - && !(mask & board.GetAttackMaps(!color))) { - board.AddMove(Move(kingSquare, targetSquare, queenCastle)); - } - } - - if (board.castlingRights & kingRight) { - U64 KingSide = color ? 0xf000000000000000 : 0xf0; - U64 mask = color ? 0x7000000000000000 : 0x70; - int targetSquare = color ? g8 : g1; - if ((Bitboard(KingSide) & board.occupied).PopCount() == 2 - && !(mask & board.GetAttackMaps(!color))) { - board.AddMove(Move(kingSquare, targetSquare, kingCastle)); - } - } -} - -// Generates moves to get out of check -static void GenCheckEvasions(Board &board, bool color) { - int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); - - // Adding moves that step out of check - GenKingMoves(board, color, true); - - Bitboard captureMask = Checkers(board, color); // Checker locations - Bitboard pushMask; // Where blockers can move to - if (captureMask.PopCount() == 1) { - int checkerSquare = captureMask.getLS1BIndex(); - int checkerType = board.GetPieceType(checkerSquare); - - if (checkerType == Rook || checkerType == Bishop || checkerType == Queen) { - pushMask = SliderRayToSquare(checkerSquare, kingSquare); - pushMask.PopBit(kingSquare); - pushMask.PopBit(checkerSquare); - } - - // looping through own pieces to add captures and blocks - for (int type = Pawn; type < King; type++) { - Bitboard currentPiece = board.colors[color] & board.pieces[type]; - - while (currentPiece) { - int square = currentPiece.getLS1BIndex(); - - if (IsPinned(board, square)) { - currentPiece.PopBit(square); - continue; - } - - Bitboard captures; - Bitboard pushes; - - if (type == Pawn) { - pushes |= getPawnPushes(square, color, board.occupied) & pushMask; - // Checking for en passant capture - if (board.enPassantTarget != noEPTarget) { - Bitboard attackedSquare = pawnAttacks[color][square] - & Bitboard::GetSquare(board.enPassantTarget); - if (attackedSquare) { - // Checking if it's legal - if (IsLegalEnPassant(board, square)) { - int direction = color ? south : north; - int targetSquare = captureMask.getLS1BIndex() + direction; - captureMask.SetBit(targetSquare); - if ((attackedSquare & pushMask) - || (attackedSquare & captureMask)) { - board.AddMove(Move(square, board.enPassantTarget, epCapture)); - } - captureMask.PopBit(targetSquare); - } - } - } - } else { - pushes |= getPieceAttacks(square, type, color, board.occupied) & pushMask; - } - - captures |= getPieceAttacks(square, type, color, board.occupied) & captureMask; - - Bitboard lastRank = color ? ranks[r_1] : ranks[r_8]; - - while (captures) { - int captureSquare = captures.getLS1BIndex(); - - // Checking for promotion - if (type == Pawn) { - if (lastRank.IsSet(captureSquare)) { - board.AddMove(Move(square, captureSquare, knightPromoCapture)); - board.AddMove(Move(square, captureSquare, bishopPromoCapture)); - board.AddMove(Move(square, captureSquare, rookPromoCapture)); - board.AddMove(Move(square, captureSquare, queenPromoCapture)); - } else { - board.AddMove(Move(square, captureSquare, capture)); - } - } else { - board.AddMove(Move(square, captureSquare, capture)); - } - - captures.PopBit(captureSquare); - } - - while (pushes) { - int pushSquare = pushes.getLS1BIndex(); - - if (type == Pawn) { - // Checking for promotion - if (lastRank.IsSet(pushSquare)) { - board.AddMove(Move(square, pushSquare, knightPromotion)); - board.AddMove(Move(square, pushSquare, bishopPromotion)); - board.AddMove(Move(square, pushSquare, rookPromotion)); - board.AddMove(Move(square, pushSquare, queenPromotion)); - } else { - if (abs(square - pushSquare) == 16) { - board.AddMove(Move(square, pushSquare, doublePawnPush)); - } else { - board.AddMove(Move(square, pushSquare, quiet)); - } - } - } else { - board.AddMove(Move(square, pushSquare, quiet)); - } - - pushes.PopBit(pushSquare); - } - - currentPiece.PopBit(square); - } - } - } else { // We can only step out of double check - return; - } -} - -void GenAttackMaps(Board &board) { - for (int color = White; color <= Black; color++) { - for (int type = Pawn; type <= King; type++) { - board.attackMaps[color][type] = 0ULL; - Bitboard pieces = board.pieces[type] & board.colors[color]; - - while (pieces) { - int square = pieces.getLS1BIndex(); - if (type == Pawn) { - board.attackMaps[color][type] |= pawnAttacks[color][square]; - } else if (type == Knight) { - board.attackMaps[color][type] |= knightAttacks[square]; - } else if (type == King) { - board.attackMaps[color][type] |= kingAttacks[square]; - } else if (type == Rook) { - board.attackMaps[color][type] |= getRookAttack(square, board.occupied - & ~(board.colors[!color] & board.pieces[King])); - } else if (type == Bishop) { - board.attackMaps[color][type] |= getBishopAttack(square, board.occupied - & ~(board.colors[!color] & board.pieces[King])); - } else if (type == Queen) { - board.attackMaps[color][type] |= getQueenAttack(square, board.occupied - & ~(board.colors[!color] & board.pieces[King])); - } - pieces.PopBit(square); - } - } - } -} - -void GenerateMoves(Board &board) { - board.ResetMoves(); - - if (board.InCheck()) { - GenCheckEvasions(board, board.sideToMove); - return; - } - - GenPawnMoves(board, board.sideToMove); - GenKnightMoves(board, board.sideToMove); - GenKingMoves(board, board.sideToMove, false); - GenBishopMoves(board, board.sideToMove); - GenRookMoves(board, board.sideToMove); - GenQueenMoves(board, board.sideToMove); -} } \ No newline at end of file diff --git a/source/movegen.h b/source/movegen.h index 04a965f..36758bc 100644 --- a/source/movegen.h +++ b/source/movegen.h @@ -3,15 +3,43 @@ #include "move.h" #include "board.h" +enum MovegenMode { + All, + Noisy +}; + namespace MOVEGEN { +inline Bitboard pawnAttacks[2][64]; +inline Bitboard knightAttacks[64]; +inline Bitboard kingAttacks[64]; + void initLeaperAttacks(); void initSliderAttacks(); -void GenAttackMaps(Board &board); +Bitboard getBishopAttack(int square, U64 occupancy); +Bitboard getRookAttack(int square, U64 occupancy); +Bitboard getQueenAttack(int square, U64 occupancy); +Bitboard getPawnPushes(int square, bool color, Bitboard &occupancy); +template +void GenPawnMoves(Board &board); +template +void GenKnightMoves(Board &board); +template +void GenRookMoves(Board &board); +template +void GenBishopMoves(Board &board); +template +void GenQueenMoves(Board &board); +template +void GenKingMoves(Board &board); + +template void GenerateMoves(Board &board); + + // bishop relevant occupancy bit count constexpr int bishopRelevantBits[64] = { 6, 5, 5, 5, 5, 5, 5, 6, @@ -169,4 +197,5 @@ constexpr U64 bishopMagicNumbers[64] = { 0x8918844842082200ULL, 0x4010011029020020ULL }; +#include "movegen.tpp" } \ No newline at end of file diff --git a/source/movegen.tpp b/source/movegen.tpp new file mode 100644 index 0000000..a275f39 --- /dev/null +++ b/source/movegen.tpp @@ -0,0 +1,91 @@ +template +void GenPawnMoves(Board &board) { + Bitboard pawns = board.pieces[Pawn] & board.colors[board.sideToMove]; + + while (pawns) { + int square = pawns.getLS1BIndex(); + + Bitboard pushes = getPawnPushes(square, board.sideToMove, board.occupied); + + Bitboard lastRank = board.sideToMove ? ranks[r_1] : ranks[r_8]; + + if constexpr (mode == Noisy) { + Bitboard captures = pawnAttacks[board.sideToMove][square] & board.colors[!board.sideToMove]; + pushes &= lastRank; + + if (board.enPassantTarget != noEPTarget) { + if (captures.IsSet(board.enPassantTarget)) { + board.AddMove(Move(square, board.enPassantTarget, epCapture)); + } + } + + while (captures) { + int targetSquare = captures.getLS1BIndex(); + + if (lastRank.IsSet(targetSquare)) { + board.AddMove(Move(square, targetSquare, knightPromoCapture)); + board.AddMove(Move(square, targetSquare, bishopPromoCapture)); + board.AddMove(Move(square, targetSquare, rookPromoCapture)); + board.AddMove(Move(square, targetSquare, queenPromoCapture)); + } else { + board.AddMove(Move(square, targetSquare, capture)); + } + + captures.PopBit(targetSquare); + } + + while (pushes) { + int pushSquare = pushes.getLS1BIndex(); + + // Only promotions because NOISY + board.AddMove(Move(square, pushSquare, knightPromotion)); + board.AddMove(Move(square, pushSquare, bishopPromotion)); + board.AddMove(Move(square, pushSquare, rookPromotion)); + board.AddMove(Move(square, pushSquare, queenPromotion)); + + pushes.PopBit(pushSquare); + } + } else { + while (pushes) { + int pushSquare = pushes.getLS1BIndex(); + + if (std::abs(square - pushSquare) == 16) { + board.AddMove(Move(square, pushSquare, doublePawnPush)); + } else { + board.AddMove(Move(square, pushSquare, quiet)); + } + + pushes.PopBit(pushSquare); + } + } + + pawns.PopBit(square); + } +} +template +void GenKnightMoves(Board &board) { +} +template +void GenRookMoves(Board &board) { +} +template +void GenBishopMoves(Board &board) { +} +template +void GenQueenMoves(Board &board) { +} +template +void GenKingMoves(Board &board) { +} + +template +void GenerateMoves(Board &board) { + board.ResetMoves(); + + GenPawnMoves(board); + GenKnightMoves(board); + GenKingMoves(board); + GenBishopMoves(board); + GenRookMoves(board); + GenQueenMoves(board); +}; \ No newline at end of file diff --git a/source/perft.cpp b/source/perft.cpp index ed8f828..9320e71 100644 --- a/source/perft.cpp +++ b/source/perft.cpp @@ -3,7 +3,7 @@ #include "movegen.h" static U64 HelperPerft(Board board, int depth) { - MOVEGEN::GenerateMoves(board); + MOVEGEN::GenerateMoves(board); if (depth == 1) return board.currentMoveIndex; if (depth == 0) return 1ULL; @@ -21,7 +21,7 @@ static U64 HelperPerft(Board board, int depth) { } void Perft(Board &board, int depth) { - MOVEGEN::GenerateMoves(board); + MOVEGEN::GenerateMoves(board); U64 totalNodes = 0; diff --git a/source/search.cpp b/source/search.cpp index 42b02b1..c1f6981 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -130,7 +130,7 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply) { alpha = bestScore; } - MOVEGEN::GenerateMoves(board); + MOVEGEN::GenerateMoves(board); SortMoves(board, ply); @@ -213,7 +213,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) { } } - MOVEGEN::GenerateMoves(board); + MOVEGEN::GenerateMoves(board); if (board.currentMoveIndex == 0) { if (board.InCheck()) { // checkmate diff --git a/source/uci.cpp b/source/uci.cpp index d9f72b4..9d6e8a2 100644 --- a/source/uci.cpp +++ b/source/uci.cpp @@ -36,8 +36,7 @@ static void ParsePosition(Board &board, std::string_view command) { } } - MOVEGEN::GenerateMoves(board); - MOVEGEN::GenAttackMaps(board); + MOVEGEN::GenerateMoves(board); } static int ReadParam(std::string param, std::string &command) { diff --git a/source/utils.cpp b/source/utils.cpp index 12f8bf6..a9b645c 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -95,7 +95,7 @@ int parseSquare(std::string_view str) { } Move parseMove(Board &board, std::string_view str) { - MOVEGEN::GenerateMoves(board); + MOVEGEN::GenerateMoves(board); int from = parseSquare(str.substr(0, 2)); int to = parseSquare(str.substr(2, 2));