diff --git a/Makefile b/Makefile index 0412a89..ba88710 100644 --- a/Makefile +++ b/Makefile @@ -17,11 +17,10 @@ OBJS := $(addprefix $(OBJ_DIR)/, $(notdir $(SRCS:.cpp=.o))) # Target executable Eleanor$(EXE_EXT): $(OBJS) - g++ -o $@ $^ - + g++ -o $@ $^ -O3 # Rule to compile source files to object files $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/types.h | $(OBJ_DIR) - g++ -c -o $@ $< + g++ -c -o $@ $< -O3 # Create the object directory if it doesn't exist $(OBJ_DIR): diff --git a/source/bitboards.cpp b/source/bitboards.cpp index 10c7539..e3a24ec 100644 --- a/source/bitboards.cpp +++ b/source/bitboards.cpp @@ -23,22 +23,16 @@ void Bitboard::PrintBoard() const { std::cout << " Board: 0x" << std::hex << m_board << '\n'; } -U64 Bitboard::GetBoard() const { - return m_board; -} - bool Bitboard::IsSet(int square) const { - return (1ULL << square) & m_board; + return GetSquare(square) & m_board; } void Bitboard::SetBit(int square) { - m_board |= (1ULL << square); + m_board |= GetSquare(square); } void Bitboard::PopBit(int square) { - if (Bitboard(m_board).IsSet(square)) { - m_board &= (~Bitboard::GetSquare(square)).GetBoard(); - } + m_board &= ~GetSquare(square); } int Bitboard::PopCount() const { @@ -86,6 +80,19 @@ Bitboard Bitboard::operator*(const Bitboard& other) const { return m_board * other.m_board; } +Bitboard Bitboard::operator&(const uint64_t& other) const { + return m_board & other; +} +Bitboard Bitboard::operator|(const uint64_t& other) const { + return m_board | other; +} +Bitboard Bitboard::operator^(const uint64_t& other) const { + return m_board ^ other; +} +Bitboard Bitboard::operator*(const uint64_t& other) const { + return m_board * other; +} + Bitboard Bitboard::operator&=(const Bitboard& other) { return m_board &= other.m_board; } @@ -96,6 +103,16 @@ Bitboard Bitboard::operator^=(const Bitboard& other) { return m_board ^= other.m_board; } +Bitboard Bitboard::operator&=(const uint64_t& other) { + return m_board &= other; +} +Bitboard Bitboard::operator|=(const uint64_t& other) { + return m_board |= other; +} +Bitboard Bitboard::operator^=(const uint64_t& other) { + return m_board ^= other; +} + Bitboard Bitboard::operator<<(int other) { if (other > 0) { return m_board << other; @@ -115,4 +132,8 @@ Bitboard Bitboard::operator>>(int other) { Bitboard Bitboard::operator~() { return ~(m_board); -} \ No newline at end of file +} + +Bitboard::operator uint64_t() { + return m_board; +} diff --git a/source/bitboards.h b/source/bitboards.h index 8f0038b..718aa00 100644 --- a/source/bitboards.h +++ b/source/bitboards.h @@ -11,8 +11,7 @@ public: Bitboard(const U64& board) : m_board(board) {} - - U64 GetBoard() const; + bool IsSet(int square) const; void SetBit(int square); void PopBit(int square); @@ -22,7 +21,7 @@ public: int getLS1BIndex() const; static Bitboard getOccupancy(int index, Bitboard attackMask); - static Bitboard GetSquare(int square) { + static Bitboard GetSquare(int square) { return (1ULL << square); }; @@ -30,12 +29,22 @@ public: Bitboard operator|(const Bitboard& other) const; Bitboard operator^(const Bitboard& other) const; Bitboard operator*(const Bitboard& other) const; + + Bitboard operator&(const uint64_t& other) const; + Bitboard operator|(const uint64_t& other) const; + Bitboard operator^(const uint64_t& other) const; + Bitboard operator*(const uint64_t& other) const; Bitboard operator&=(const Bitboard& other); Bitboard operator|=(const Bitboard& other); Bitboard operator^=(const Bitboard& other); + Bitboard operator&=(const uint64_t& other); + Bitboard operator|=(const uint64_t& other); + Bitboard operator^=(const uint64_t& other); + Bitboard operator<<(int other); Bitboard operator>>(int other); Bitboard operator~(); -}; \ No newline at end of file + operator uint64_t(); +}; diff --git a/source/board.cpp b/source/board.cpp index fee5ad7..a81308f 100644 --- a/source/board.cpp +++ b/source/board.cpp @@ -1,5 +1,4 @@ #include "board.h" -#include "movegen.h" #include void Board::Init() { @@ -7,7 +6,7 @@ void Board::Init() { } void Board::Reset() { - castlingRights = { false, false, false, false }; + castlingRights = 0; enPassantTarget = -1; halfMoves = 0; fullMoves = 0; @@ -16,6 +15,8 @@ void Board::Reset() { pieces = std::array(); colors = std::array(); + + moveList = std::array(); } void Board::SetByFen(const char* fen) { @@ -79,7 +80,7 @@ void Board::SetByFen(const char* fen) { pieceColor = White; break; case '/': - currentSquare = currentSquare >> 8 + digits; + currentSquare = currentSquare >> (8 + digits); digits = 0; fen++; continue; @@ -123,16 +124,16 @@ void Board::SetByFen(const char* fen) { } break; case 'K': - castlingRights[White] = true; + castlingRights |= whiteKingRight; break; case 'Q': - castlingRights[White + 1] = true; + castlingRights |= whiteQueenRight; break; case 'k': - castlingRights[Black * 2] = true; + castlingRights |= blackKingRight; break; case 'q': - castlingRights[Black * 2 + 1] = true; + castlingRights |= blackQueenRight; break; default: if (*fen != '-') { @@ -183,7 +184,6 @@ void Board::SetByFen(const char* fen) { } occupied = (colors[White] | colors[Black]); - GenAttackMaps(*this); } void Board::PrintBoard() { @@ -229,26 +229,27 @@ void Board::PrintBoard() { } std::cout << " Castling rights: "; - if (castlingRights[0]) std::cout << "K"; else std::cout << "-"; - if (castlingRights[1]) std::cout << "Q"; else std::cout << "-"; - if (castlingRights[2]) std::cout << "k"; else std::cout << "-"; - if (castlingRights[3]) std::cout << "q"; else std::cout << "-"; + if (castlingRights & whiteKingRight) std::cout << "K"; else std::cout << "-"; + if (castlingRights & whiteQueenRight) std::cout << "Q"; else std::cout << "-"; + if (castlingRights & blackKingRight) std::cout << "k"; else std::cout << "-"; + if (castlingRights & blackQueenRight) std::cout << "q"; else std::cout << "-"; std::cout << '\n'; } void Board::AddMove(Move move) { - moveList.push_back(move); + moveList[currentMoveIndex] = move; + currentMoveIndex++; } void Board::ResetMoves() { - moveList.clear(); + currentMoveIndex = 0; } void Board::ListMoves() { int count = 1; - for (Move move : moveList) { + for (int i = 0; i < currentMoveIndex; i++) { std::cout << count << ". "; - move.PrintMove(); + moveList[i].PrintMove(); count++; } } @@ -265,18 +266,8 @@ int Board::GetPieceColor(int square) { return (colors[Black].IsSet(square)); } -U64 Board::GetAttackMaps(bool side) { - U64 combined = 0ULL; - for (int type = Pawn; type <= King; type++) { - combined |= attackMaps[side][type]; - } - return combined; -} - bool Board::InCheck(bool side) { - Bitboard myKingSquare = colors[side] & pieces[King]; - return GetAttackMaps(!side) & myKingSquare.GetBoard(); } void Board::SetPiece(int piece, int square, bool color) { @@ -298,13 +289,13 @@ static void UpdateCastlingRights(Board &board, int square, int type, int color) int kingSideRook = color ? h8 : h1; if (square == queenSideRook) { - board.castlingRights[color * 2 + 1] = false; + board.castlingRights &= color ? blackQueenRight : whiteQueenRight; } else if (square == kingSideRook) { - board.castlingRights[color * 2] = false; + board.castlingRights &= color ? blackKingRight : whiteKingRight; } } else if (type == King) { - board.castlingRights[color * 2 + 1] = false; - board.castlingRights[color * 2] = false; + board.castlingRights &= color ? blackQueenRight : whiteQueenRight; + board.castlingRights &= color ? blackKingRight : whiteKingRight; } } @@ -408,9 +399,7 @@ void Board::MakeMove(Move move) { UpdateCastlingRights(*this, move.MoveFrom(), attackerPiece, attackerColor); halfMoves++; - if (halfMoves & 2 == 0) fullMoves++; + if (halfMoves % 2 == 0) fullMoves++; sideToMove = !attackerColor; enPassantTarget = newEpTarget; - - GenAttackMaps(*this); -} \ No newline at end of file +} diff --git a/source/board.h b/source/board.h index 12af5c9..5af5cbd 100644 --- a/source/board.h +++ b/source/board.h @@ -3,7 +3,6 @@ #include "bitboards.h" #include "types.h" #include "move.h" -#include class Board { public: @@ -13,17 +12,17 @@ public: std::array pieces; std::array colors; - U64 attackMaps[2][64]; Bitboard occupied; - std::vector moveList; + std::array moveList; + int currentMoveIndex = 0; bool sideToMove = White; int halfMoves = 0; int fullMoves = 0; - std::array castlingRights = { false, false, false, false }; + uint8_t castlingRights = 0; int enPassantTarget; void Init(); @@ -38,7 +37,6 @@ public: int GetPieceType(int square); int GetPieceColor(int square); - U64 GetAttackMaps(bool side); bool InCheck(bool side); void SetPiece(int piece, int square, bool color); @@ -46,4 +44,4 @@ public: void Promote(int square, int pieceType, int color, bool isCapture); void MakeMove(Move move); -}; \ No newline at end of file +}; diff --git a/source/evaluate.cpp b/source/evaluate.cpp index a2f63e0..a939849 100644 --- a/source/evaluate.cpp +++ b/source/evaluate.cpp @@ -13,7 +13,7 @@ static int GetPositionalScore(Board &board, int type, int color) { Bitboard pieces = board.pieces[type] & board.colors[color]; - while (pieces.GetBoard()) { + while (pieces) { int square = pieces.getLS1BIndex(); // White diff --git a/source/main.cpp b/source/main.cpp index 996e312..1f98727 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -11,7 +11,9 @@ int main() { Board board; - UCILoop(board); + // UCILoop(board); + + Perft(board, 6); return 0; -} \ No newline at end of file +} diff --git a/source/movegen.cpp b/source/movegen.cpp index 1281913..b8e8fc3 100644 --- a/source/movegen.cpp +++ b/source/movegen.cpp @@ -18,51 +18,51 @@ static Bitboard notHGfile = notHfile & ~files[G]; Bitboard maskPawnAttacks(int side, int square) { Bitboard attacks; - Bitboard attacker = Bitboard::GetSquare(square); + Bitboard attacker = Bitboard::GetSquare(square); // White if (!side) { - if (((attacker << noEa) & notAfile).GetBoard()) attacks |= (attacker << noEa); - if (((attacker << noWe) & notHfile).GetBoard()) attacks |= (attacker << noWe); + if (((attacker << noEa) & notAfile)) attacks |= (attacker << noEa); + if (((attacker << noWe) & notHfile)) attacks |= (attacker << noWe); } // Black else { - if (((attacker << soEa) & notAfile).GetBoard()) attacks |= (attacker << soEa); - if (((attacker << soWe) & notHfile).GetBoard()) attacks |= (attacker << soWe); + if (((attacker << soEa) & notAfile)) attacks |= (attacker << soEa); + if (((attacker << soWe) & notHfile)) attacks |= (attacker << soWe); } return attacks; } Bitboard maskKnightAttacks(int square) { Bitboard attacks; - Bitboard attacker = Bitboard::GetSquare(square); + Bitboard attacker = Bitboard::GetSquare(square); - if (((attacker << noEa + north) & notAfile).GetBoard()) attacks |= (attacker << noEa + north); - if (((attacker << noWe + north) & notHfile).GetBoard()) attacks |= (attacker << noWe + north); - if (((attacker << noWe + west) & notHGfile).GetBoard()) attacks |= (attacker << noWe + west); - if (((attacker << noEa + east) & notABfile).GetBoard()) attacks |= (attacker << noEa + east); + if (((attacker << noEa + north) & notAfile)) attacks |= (attacker << noEa + north); + if (((attacker << noWe + north) & notHfile)) attacks |= (attacker << noWe + north); + if (((attacker << noWe + west) & notHGfile)) attacks |= (attacker << noWe + west); + if (((attacker << noEa + east) & notABfile)) attacks |= (attacker << noEa + east); - if (((attacker << soWe + south) & notHfile).GetBoard()) attacks |= (attacker << soWe + south); - if (((attacker << soEa + south) & notAfile).GetBoard()) attacks |= (attacker << soEa + south); - if (((attacker << soEa + east) & notABfile).GetBoard()) attacks |= (attacker << soEa + east); - if (((attacker << soWe + west) & notHGfile).GetBoard()) attacks |= (attacker << soWe + west); + if (((attacker << soWe + south) & notHfile)) attacks |= (attacker << soWe + south); + if (((attacker << soEa + south) & notAfile)) attacks |= (attacker << soEa + south); + if (((attacker << soEa + east) & notABfile)) attacks |= (attacker << soEa + east); + if (((attacker << soWe + west) & notHGfile)) attacks |= (attacker << soWe + west); return attacks; } Bitboard maskKingAttacks(int square) { Bitboard attacks; - Bitboard attacker = Bitboard::GetSquare(square); + Bitboard attacker = Bitboard::GetSquare(square); attacks |= (attacker << north); attacks |= (attacker << south); - if (((attacker << west) & notHfile).GetBoard()) attacks |= (attacker << west); - if (((attacker << soWe) & notHfile).GetBoard()) attacks |= (attacker << soWe); - if (((attacker << soEa) & notAfile).GetBoard()) attacks |= (attacker << soEa); - if (((attacker << east) & notAfile).GetBoard()) attacks |= (attacker << east); - if (((attacker << noEa) & notAfile).GetBoard()) attacks |= (attacker << noEa); - if (((attacker << noWe) & notHfile).GetBoard()) attacks |= (attacker << noWe); + if (((attacker << west) & notHfile)) attacks |= (attacker << west); + if (((attacker << soWe) & notHfile)) attacks |= (attacker << soWe); + if (((attacker << soEa) & notAfile)) attacks |= (attacker << soEa); + if (((attacker << east) & notAfile)) attacks |= (attacker << east); + if (((attacker << noEa) & notAfile)) attacks |= (attacker << noEa); + if (((attacker << noWe) & notHfile)) attacks |= (attacker << noWe); return attacks; } @@ -140,25 +140,25 @@ Bitboard bishopAttacksOnTheFly(int square, Bitboard block) { for (int r = tr + 1, f = tf - 1; r <= 7 && f >= 0; r++, f--) { currentSquare = (1ULL << (r * 8 + f)); attacks |= currentSquare; - if ((currentSquare & block).GetBoard()) break; + if ((currentSquare & block)) break; } // North East for (int r = tr + 1, f = tf + 1; r <= 7 && f <= 7; r++, f++) { currentSquare = (1ULL << (r * 8 + f)); attacks |= currentSquare; - if ((currentSquare & block).GetBoard()) break; + if ((currentSquare & block)) break; } //South West for (int r = tr - 1, f = tf - 1; r >= 0 && f >= 0; r--, f--) { currentSquare = (1ULL << (r * 8 + f)); attacks |= currentSquare; - if ((currentSquare & block).GetBoard()) break; + if ((currentSquare & block)) break; } //South East for (int r = tr - 1, f = tf + 1; r >= 0 && f <= 7; r--, f++) { currentSquare = (1ULL << (r * 8 + f)); attacks |= currentSquare; - if ((currentSquare & block).GetBoard()) break; + if ((currentSquare & block)) break; } return attacks; @@ -179,25 +179,25 @@ Bitboard rookAttacksOnTheFly(int square, Bitboard block) { for (int r = tr + 1; r <= 7; r++) { currentSquare = (1ULL << (r * 8 + tf)); attacks |= currentSquare; - if ((currentSquare & block).GetBoard()) break; + if ((currentSquare & block)) break; } // South for (int r = tr - 1; r >= 0; r--) { currentSquare = (1ULL << (r * 8 + tf)); attacks |= currentSquare; - if ((currentSquare & block).GetBoard()) break; + if ((currentSquare & block)) break; } // East for (int f = tf + 1; f <= 7; f++) { currentSquare = (1ULL << (tr * 8 + f)); attacks |= currentSquare; - if ((currentSquare & block).GetBoard()) break; + if ((currentSquare & block)) break; } // West for (int f = tf - 1; f >= 0; f--) { currentSquare = (1ULL << (tr * 8 + f)); attacks |= currentSquare; - if ((currentSquare & block).GetBoard()) break; + if ((currentSquare & block)) break; } return attacks; @@ -221,7 +221,7 @@ void initSliderAttacks() { for (int index = 0; index < 512; index++) { Bitboard occupancy = Bitboard::getOccupancy(index, bishopMasks[square]); - int magicIndex = (occupancy.GetBoard() * bishopMagicNumbers[square]) + int magicIndex = (occupancy * bishopMagicNumbers[square]) >> (64 - bishopRelevantBits[square]); bishopAttacks[square][magicIndex] = bishopAttacksOnTheFly(square, occupancy); @@ -230,7 +230,7 @@ void initSliderAttacks() { for (int index = 0; index < 4096; index++) { Bitboard occupancy = Bitboard::getOccupancy(index, rookMasks[square]); - int magicIndex = (occupancy.GetBoard() * rookMagicNumbers[square]) + int magicIndex = (occupancy * rookMagicNumbers[square]) >> (64 - rookRelevantBits[square]); rookAttacks[square][magicIndex] = rookAttacksOnTheFly(square, occupancy); @@ -239,7 +239,7 @@ void initSliderAttacks() { } Bitboard getBishopAttack(int square, U64 occupancy) { - occupancy &= bishopMasks[square].GetBoard(); + occupancy &= bishopMasks[square]; occupancy *= bishopMagicNumbers[square]; occupancy >>= (64 - bishopRelevantBits[square]); @@ -247,7 +247,7 @@ Bitboard getBishopAttack(int square, U64 occupancy) { } Bitboard getRookAttack(int square, U64 occupancy) { - occupancy &= rookMasks[square].GetBoard(); + occupancy &= rookMasks[square]; occupancy *= rookMagicNumbers[square]; occupancy >>= (64 - rookRelevantBits[square]); @@ -258,11 +258,11 @@ Bitboard getQueenAttack(int square, U64 occupancy) { U64 bishopOccupancy = occupancy; U64 rookOccupancy = occupancy; - bishopOccupancy &= bishopMasks[square].GetBoard(); + bishopOccupancy &= bishopMasks[square]; bishopOccupancy *= bishopMagicNumbers[square]; bishopOccupancy >>= (64 - bishopRelevantBits[square]); - rookOccupancy &= rookMasks[square].GetBoard(); + rookOccupancy &= rookMasks[square]; rookOccupancy *= rookMagicNumbers[square]; rookOccupancy >>= (64 - rookRelevantBits[square]); @@ -286,311 +286,97 @@ Bitboard getPieceAttacks(int square, int piece, int color, U64 occupancy) { } static Bitboard getPawnPushes(int square, bool color, Bitboard &occupancy) { - Bitboard pushes; + Bitboard pushes; - int direction = color ? south : north; - Bitboard secondRank = color ? ranks[r_7] : ranks[r_2]; + int direction = color ? south : north; + Bitboard secondRank = color ? ranks[r_7] : ranks[r_2]; - if (!occupancy.IsSet(square + direction)) { - pushes.SetBit(square + direction); + if (!occupancy.IsSet(square + direction)) { + pushes.SetBit(square + direction); - if (secondRank.IsSet(square) && !occupancy.IsSet(square + 2 * direction)) { - pushes.SetBit(square + 2 * direction); - } - } + if (secondRank.IsSet(square) && !occupancy.IsSet(square + 2 * direction)) { + pushes.SetBit(square + 2 * direction); + } + } - return pushes; -} - -// Returns bitboard of checkers -static Bitboard Checkers(Board &board, bool color) { - int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); - Bitboard checkerBoard = 0ULL; - - for (int type = Pawn; type < King; type++) { - Bitboard targets = getPieceAttacks(kingSquare, type, color, board.occupied.GetBoard()); - checkerBoard |= targets & board.pieces[type] & board.colors[!color]; - } - return checkerBoard; -} - -// Returns the direction to target from square -static int GetDirection(int square, int target) { - int rankDiff = (target / 8) - (square / 8); - int fileDiff = (target % 8) - (square % 8); - - // Main directions - if (rankDiff == 0 && fileDiff < 0) { - return west; - } else if (rankDiff == 0 && fileDiff > 0) { - return east; - } else if (rankDiff < 0 && fileDiff == 0) { - return south; - } else if (rankDiff > 0 && fileDiff == 0) { - return north; - } - - // Diagonals - if (abs(rankDiff) == abs(fileDiff)) { - if (rankDiff < 0 && fileDiff < 0) { - return soWe; - } else if (rankDiff < 0 && fileDiff > 0) { - return soEa; - } else if (rankDiff > 0 && fileDiff < 0) { - return noWe; - } else if (rankDiff > 0 && fileDiff > 0) { - return noEa; - } - } - - return 0; -} - -// Returns a bitboard of the squares from attacker to target -static Bitboard SliderRayToSquare(int attacker, int target) { - Bitboard ray; - int direction = GetDirection(attacker, target); - - if (direction) { - while (attacker != target) { - ray.SetBit(attacker); - attacker += direction; - } - ray.SetBit(target); - } - - return ray; -} - -static Bitboard GetPinningRay(Board &board, int square, int direction) { - Bitboard ray; - int currentSquare = (board.pieces[King] & board.colors[board.sideToMove]).getLS1BIndex(); - int previousRank = currentSquare / 8; - - currentSquare += direction; - while (currentSquare < 64 && currentSquare >= 0) { - int currentRank = currentSquare / 8; - - int difference = abs(currentRank - previousRank); - - if ((abs(direction) == 7 || abs(direction) == 9) - && difference != 1) { - break; - } else if (abs(direction) == 1 && difference) { - break; - } - previousRank = currentRank; - - ray.SetBit(currentSquare); - if (board.occupied.IsSet(currentSquare)) { - if (currentSquare == square) { - currentSquare += direction; - continue; - } - int attackerType = board.GetPieceType(currentSquare); - int attackerColor = board.GetPieceColor(currentSquare); - - if (attackerColor != board.sideToMove) { - // Pinned by rook or queen - if (abs(direction) == 1 || abs(direction) == 8) { - if (attackerType == Rook || attackerType == Queen) { - return ray; - } - // Pinned by bishop or queen - } else if (direction % 2 != 0) { - if (attackerType == Bishop || attackerType == Queen) { - return ray; - } - } - } - break; - } - currentSquare += direction; - } - - return 0ULL; -} - -static bool IsPinned(Board &board, int square) { - int kingSquare = (board.colors[board.sideToMove] & board.pieces[King]).getLS1BIndex(); - int directionToKing = GetDirection(square, kingSquare); - - if (directionToKing) { - // Checking if there are any pieces between square and kingSquare - if ((SliderRayToSquare(square, kingSquare) - & board.occupied).PopCount() != 2) { - return false; - } - - return GetPinningRay(board, square, -directionToKing).PopCount(); - } - - 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; -} + return pushes; +} static void GenPawnMoves(Board &board, bool color) { - Bitboard pawns = board.colors[color] & board.pieces[Pawn]; + Bitboard pawns = board.pieces[Pawn] & board.colors[color]; - while (pawns.GetBoard()) { - int square = pawns.getLS1BIndex(); + while (pawns) { + int square = pawns.getLS1BIndex(); + Bitboard seventhRank = color ? ranks[r_2] : ranks[r_7]; - Bitboard pushes = getPawnPushes(square, color, board.occupied); - Bitboard captures = pawnAttacks[color][square]; + Bitboard pushes = getPawnPushes(square, color, board.occupied); + Bitboard captures = pawnAttacks[color][square] & board.colors[!color]; - if (IsPinned(board, square)) { - int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); - int directionToKing = GetDirection(square, kingSquare); + if (seventhRank.IsSet(square)) { + while (pushes) { + int targetSquare = pushes.getLS1BIndex(); - Bitboard pinningRay = GetPinningRay(board, square, -directionToKing); - pushes &= pinningRay; - captures &= pinningRay; + board.AddMove(Move(square, targetSquare, queenPromotion)); + board.AddMove(Move(square, targetSquare, rookPromotion)); + board.AddMove(Move(square, targetSquare, bishopPromotion)); + board.AddMove(Move(square, targetSquare, knightPromotion)); - // Checking for en passant - if (captures.IsSet(board.enPassantTarget)) { - if (IsLegalEnPassant(board, square)) { - board.AddMove(Move(square, board.enPassantTarget, epCapture)); - } - } + pushes.PopBit(targetSquare); + } - // Removing own pieces from capture mask - captures &= board.colors[!color]; + while (captures) { + int targetSquare = captures.getLS1BIndex(); - while (pushes.GetBoard()) { - int pushSquare = pushes.getLS1BIndex(); + board.AddMove(Move(square, targetSquare, queenPromoCapture)); + board.AddMove(Move(square, targetSquare, rookPromoCapture)); + board.AddMove(Move(square, targetSquare, bishopPromoCapture)); + board.AddMove(Move(square, targetSquare, knightPromoCapture)); - if (abs(square - pushSquare) == 16) { - board.AddMove(Move(square, pushSquare, doublePawnPush)); - } else { - board.AddMove(Move(square, pushSquare, quiet)); - } + captures.PopBit(targetSquare); + } + } else { + while (pushes) { + int targetSquare = pushes.getLS1BIndex(); - pushes.PopBit(pushSquare); - } + // Checking for double push + if (abs(targetSquare - square) == 16) { + board.AddMove(Move(square, targetSquare, doublePawnPush)); + } else { + board.AddMove(Move(square, targetSquare, quiet)); + } - while (captures.GetBoard()) { - int targetSquare = captures.getLS1BIndex(); + pushes.PopBit(targetSquare); + } - board.AddMove(Move(square, targetSquare, capture)); + while (captures) { + int targetSquare = captures.getLS1BIndex(); - captures.PopBit(targetSquare); - } + board.AddMove(Move(square, targetSquare, capture)); - pawns.PopBit(square); - continue; - } + captures.PopBit(targetSquare); + } - // Checking for en passant - 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)); - } - } + // Checking for en passant + if (pawnAttacks[color][square].IsSet(board.enPassantTarget)) { + board.AddMove(Move(square, board.enPassantTarget, epCapture)); + } + } - // Removing own pieces from capture mask - captures &= board.colors[!color]; - - Bitboard lastRank = color ? ranks[r_1] : ranks[r_8]; - - while (pushes.GetBoard()) { - 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.GetBoard()) { - 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); - } + pawns.PopBit(square); + } } static void GenKnightMoves(Board &board, bool color) { Bitboard knights = board.colors[color] & board.pieces[Knight]; - while (knights.GetBoard()) { + 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; + Bitboard quietMoves = moves & ~board.colors[!color]; - while (moves.GetBoard()) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures.GetBoard()) { + while (captures) { int targetSquare = captures.getLS1BIndex(); board.AddMove(Move(square, targetSquare, capture)); @@ -598,59 +384,29 @@ static void GenKnightMoves(Board &board, bool color) { captures.PopBit(targetSquare); } + while (quietMoves) { + int targetSquare = quietMoves.getLS1BIndex(); + + board.AddMove(Move(square, targetSquare, quiet)); + + quietMoves.PopBit(targetSquare); + } + knights.PopBit(square); - } + } } static void GenRookMoves(Board &board, bool color) { - Bitboard rooks = board.colors[color] & board.pieces[Rook]; + Bitboard rooks = board.pieces[Rook] & board.colors[color]; - while (rooks.GetBoard()) { - int square = rooks.getLS1BIndex(); + while (rooks) { + int square = rooks.getLS1BIndex(); - Bitboard moves = getRookAttack(square, board.occupied.GetBoard()) & ~board.colors[color]; + Bitboard moves = getRookAttack(square, board.occupied) & ~board.colors[color]; Bitboard captures = moves & board.colors[!color]; - moves &= ~captures; + Bitboard quietMoves = moves & ~board.colors[!color]; - 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.GetBoard()) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures.GetBoard()) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - rooks.PopBit(square); - continue; - } - - - while (moves.GetBoard()) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures.GetBoard()) { + while (captures) { int targetSquare = captures.getLS1BIndex(); board.AddMove(Move(square, targetSquare, capture)); @@ -658,332 +414,128 @@ static void GenRookMoves(Board &board, bool color) { captures.PopBit(targetSquare); } - rooks.PopBit(square); - } + while (quietMoves) { + int targetSquare = quietMoves.getLS1BIndex(); + + board.AddMove(Move(square, targetSquare, quiet)); + + quietMoves.PopBit(targetSquare); + } + + rooks.PopBit(square); + } } static void GenBishopMoves(Board &board, bool color) { - Bitboard bishops = board.colors[color] & board.pieces[Bishop]; + Bitboard bishops = board.pieces[Bishop] & board.colors[color]; - while (bishops.GetBoard()) { - int square = bishops.getLS1BIndex(); + while (bishops) { + int square = bishops.getLS1BIndex(); - Bitboard moves = getBishopAttack(square, board.occupied.GetBoard()) & ~board.colors[color]; - Bitboard captures = moves & board.colors[!color]; - moves &= ~captures; + Bitboard moves = getBishopAttack(square, board.occupied) & ~board.colors[color]; + Bitboard captures = moves & board.colors[!color]; + Bitboard quietMoves = moves & ~board.colors[!color]; - if (IsPinned(board, square)) { - int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); - int directionToKing = GetDirection(square, kingSquare); + while (captures) { + int targetSquare = captures.getLS1BIndex(); - Bitboard pinningRay = GetPinningRay(board, square, -directionToKing); + board.AddMove(Move(square, targetSquare, capture)); - moves &= pinningRay; - captures &= pinningRay; + captures.PopBit(targetSquare); + } - while (moves.GetBoard()) { - int targetSquare = moves.getLS1BIndex(); + while (quietMoves) { + int targetSquare = quietMoves.getLS1BIndex(); - board.AddMove(Move(square, targetSquare, quiet)); + board.AddMove(Move(square, targetSquare, quiet)); - moves.PopBit(targetSquare); - } + quietMoves.PopBit(targetSquare); + } - while (captures.GetBoard()) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - bishops.PopBit(square); - continue; - } - - - while (moves.GetBoard()) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures.GetBoard()) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - bishops.PopBit(square); - } + bishops.PopBit(square); + } } static void GenQueenMoves(Board &board, bool color) { - Bitboard queens = board.colors[color] & board.pieces[Queen]; + Bitboard queens = board.pieces[Queen] & board.colors[color]; - while (queens.GetBoard()) { - int square = queens.getLS1BIndex(); + while (queens) { + int square = queens.getLS1BIndex(); - Bitboard moves = getQueenAttack(square, board.occupied.GetBoard()) & ~board.colors[color]; - Bitboard captures = moves & board.colors[!color]; - moves &= ~captures; + Bitboard moves = getQueenAttack(square, board.occupied) & ~board.colors[color]; + Bitboard captures = moves & board.colors[!color]; + Bitboard quietMoves = moves & ~board.colors[!color]; - if (IsPinned(board, square)) { - int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); - int directionToKing = GetDirection(square, kingSquare); + while (captures) { + int targetSquare = captures.getLS1BIndex(); - Bitboard pinningRay = GetPinningRay(board, square, -directionToKing); + board.AddMove(Move(square, targetSquare, capture)); - moves &= pinningRay; - captures &= pinningRay; + captures.PopBit(targetSquare); + } - while (moves.GetBoard()) { - int targetSquare = moves.getLS1BIndex(); + while (quietMoves) { + int targetSquare = quietMoves.getLS1BIndex(); - board.AddMove(Move(square, targetSquare, quiet)); + board.AddMove(Move(square, targetSquare, quiet)); - moves.PopBit(targetSquare); - } + quietMoves.PopBit(targetSquare); + } - while (captures.GetBoard()) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - queens.PopBit(square); - continue; - } - - - while (moves.GetBoard()) { - int targetSquare = moves.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, quiet)); - - moves.PopBit(targetSquare); - } - - while (captures.GetBoard()) { - int targetSquare = captures.getLS1BIndex(); - - board.AddMove(Move(square, targetSquare, capture)); - - captures.PopBit(targetSquare); - } - - queens.PopBit(square); - } + queens.PopBit(square); + } } -static void GenKingMoves(Board &board, bool color, bool isInCheck) { - int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); +static void GenKingMoves(Board &board, bool color) { + int kingSquare = (board.pieces[King] & board.colors[color]).getLS1BIndex(); - Bitboard moves = (kingAttacks[kingSquare] & ~board.GetAttackMaps(!color)) & ~board.colors[color]; - Bitboard captures = moves & board.colors[!color]; - moves &= ~board.colors[!color]; + Bitboard moves = kingAttacks[kingSquare] & ~board.colors[color]; + Bitboard captures = moves & board.colors[!color]; + Bitboard quietMoves = moves & ~board.colors[!color]; - while (moves.GetBoard()) { - int square = moves.getLS1BIndex(); + while (captures) { + int targetSquare = captures.getLS1BIndex(); - board.AddMove(Move(kingSquare, square, quiet)); + board.AddMove(Move(kingSquare, targetSquare, capture)); - moves.PopBit(square); - } + captures.PopBit(targetSquare); + } - while (captures.GetBoard()) { - int square = captures.getLS1BIndex(); + while (quietMoves) { + int targetSquare = quietMoves.getLS1BIndex(); - Move move(kingSquare, square, capture); - board.AddMove(move); + board.AddMove(Move(kingSquare, targetSquare, quiet)); - captures.PopBit(square); - } + quietMoves.PopBit(targetSquare); + } - // Generating castles - if (!isInCheck) { - if (board.castlingRights[color * 2 + 1]) { - 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)); - } - } + // Checking for king side castle + if (board.castlingRights & (whiteKingRight | blackKingRight)) { + Bitboard mask = color ? 0xe000000000000000 : 0xe0; - if (board.castlingRights[color * 2]) { - 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)); - } - } - } + if ((board.occupied & mask).PopCount() == 1) { + board.AddMove(Move(kingSquare, kingSquare + 2, kingCastle)); + } + } + + // Checking for queen side castle + if (board.castlingRights & (whiteQueenRight | blackQueenRight)) { + Bitboard mask = color ? 0xf00000000000000 : 0xf; + + if ((board.occupied & mask).PopCount() == 1) { + board.AddMove(Move(kingSquare, kingSquare - 2, queenCastle)); + } + } } -// 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.GetBoard()) { - 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 - Bitboard attackedSquare = pawnAttacks[color][square] - & Bitboard::GetSquare(board.enPassantTarget); - if (attackedSquare.GetBoard()) { - // 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).GetBoard() - || (attackedSquare & captureMask).GetBoard()) { - board.AddMove(Move(square, board.enPassantTarget, epCapture)); - } - captureMask.PopBit(targetSquare); - } - } - } else { - pushes |= getPieceAttacks(square, type, color, board.occupied.GetBoard()) & pushMask; - } - - captures |= getPieceAttacks(square, type, color, board.occupied.GetBoard()) & captureMask; - - Bitboard lastRank = color ? ranks[r_1] : ranks[r_8]; - - while (captures.GetBoard()) { - 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.GetBoard()) { - 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.GetBoard()) { - int square = pieces.getLS1BIndex(); - if (type == Pawn) { - board.attackMaps[color][type] |= pawnAttacks[color][square].GetBoard(); - } else if (type == Knight) { - board.attackMaps[color][type] |= knightAttacks[square].GetBoard(); - } else if (type == King) { - board.attackMaps[color][type] |= kingAttacks[square].GetBoard(); - } else if (type == Rook) { - board.attackMaps[color][type] |= getRookAttack(square, (board.occupied - & ~(board.colors[!color] & board.pieces[King])).GetBoard()).GetBoard(); - } else if (type == Bishop) { - board.attackMaps[color][type] |= getBishopAttack(square, (board.occupied - & ~(board.colors[!color] & board.pieces[King])).GetBoard()).GetBoard(); - } else if (type == Queen) { - board.attackMaps[color][type] |= getQueenAttack(square, (board.occupied - & ~(board.colors[!color] & board.pieces[King])).GetBoard()).GetBoard(); - } - pieces.PopBit(square); - } - } - } -} - -void GenerateMoves(Board &board, bool side) { - board.moveList.clear(); - - if (board.InCheck(side)) { - GenCheckEvasions(board, side); - return; - } +void GenerateMoves(Board &board) { + bool side = board.sideToMove; + board.ResetMoves(); GenPawnMoves(board, side); - GenKnightMoves(board, side); - GenKingMoves(board, side, false); + GenKnightMoves(board, side); + GenKingMoves(board, side); GenBishopMoves(board, side); GenRookMoves(board, side); GenQueenMoves(board, side); -} \ No newline at end of file +} diff --git a/source/movegen.h b/source/movegen.h index 98f3eee..abae6b2 100644 --- a/source/movegen.h +++ b/source/movegen.h @@ -208,6 +208,4 @@ Bitboard getQueenAttack(int square, U64 occupancy); // Returns attacks regardless of board (so occupancy is 0ULL) Bitboard getPieceAttacks(int square, int piece, int color); -void GenAttackMaps(Board &board); - -void GenerateMoves(Board &board, bool side); \ No newline at end of file +void GenerateMoves(Board &board); \ No newline at end of file diff --git a/source/perft.cpp b/source/perft.cpp index 4cd6265..3273ccc 100644 --- a/source/perft.cpp +++ b/source/perft.cpp @@ -2,33 +2,31 @@ #include "perft.h" U64 HelperPerft(Board board, int depth) { - GenerateMoves(board, board.sideToMove); + GenerateMoves(board); - if (depth == 1) return board.moveList.size(); + if (depth == 1) return board.currentMoveIndex; if (depth == 0) return 1ULL; U64 nodes = 0; - for (int i = 0; i < board.moveList.size(); i++) { + for (int i = 0; i < board.currentMoveIndex; i++) { Board copy = board; - board.MakeMove(board.moveList[i]); - nodes += HelperPerft(board, depth - 1); - board = copy; + copy.MakeMove(board.moveList[i]); + nodes += HelperPerft(copy, depth - 1); } return nodes; } void Perft(Board &board, int depth) { - GenerateMoves(board, board.sideToMove); + GenerateMoves(board); U64 totalNodes = 0; auto start = std::chrono::steady_clock::now(); - for (int i = 0; i < board.moveList.size(); i++) { + for (int i = 0; i < board.currentMoveIndex; i++) { Board copy = board; - board.MakeMove(board.moveList[i]); - U64 nodeCount = HelperPerft(board, depth - 1); - board = copy; + copy.MakeMove(board.moveList[i]); + U64 nodeCount = HelperPerft(copy, depth - 1); totalNodes += nodeCount; std::cout << squareCoords[board.moveList[i].MoveFrom()] << squareCoords[board.moveList[i].MoveTo()]; @@ -56,4 +54,4 @@ void Perft(Board &board, int depth) { std::cout << "Total nodes: " << totalNodes << '\n'; std::cout << "Time took: " << elapsed_seconds << "s ("; std::cout << int(totalNodes / elapsed_seconds) << " nodes/sec)\n"; -} \ No newline at end of file +} diff --git a/source/search.cpp b/source/search.cpp index d4569fc..d78ebbc 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -17,7 +17,7 @@ int Quiescence(Board board, int alpha, int beta) { alpha = staticScore; } - GenerateMoves(board, board.sideToMove); + GenerateMoves(board); for (Move move : board.moveList) { if (move.IsCapture()) { @@ -40,7 +40,7 @@ int Quiescence(Board board, int alpha, int beta) { } int NegaMax(Board board, int depth, int alpha, int beta, bool isRoot) { - GenerateMoves(board, board.sideToMove); + GenerateMoves(board); if (board.moveList.size() == 0) { if (board.InCheck(board.sideToMove)) { // checkmate diff --git a/source/types.h b/source/types.h index 7b1cd65..809a86d 100644 --- a/source/types.h +++ b/source/types.h @@ -20,6 +20,13 @@ enum PIECE { King }; +enum CASTLING_RIGHTS { + whiteKingRight = 1, + whiteQueenRight = 2, + blackKingRight = 4, + blackQueenRight = 8 +}; + constexpr std::array PIECE_LETTERS = { 'P', 'p', 'N', 'n', @@ -87,4 +94,4 @@ enum DIRECTION { noEa = north + east, soWe = south + west, soEa = south + east -}; \ No newline at end of file +}; diff --git a/source/uci.cpp b/source/uci.cpp index a1b94f0..c03f2e0 100644 --- a/source/uci.cpp +++ b/source/uci.cpp @@ -7,7 +7,7 @@ #include "search.h" Move ParseMove(Board &board, const char* moveString) { - GenerateMoves(board, board.sideToMove); + GenerateMoves(board); // Source square std::string fromString = "";