#ifndef SRC_BOARD_H_ #define SRC_BOARD_H_ #include #include enum PieceType { NONEPIECE, PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING, }; enum GameState { TURN, WHITE_WON, BLACK_WON, DRAW, }; struct Piece { bool color = false; PieceType type = NONEPIECE; }; struct Position { uint8_t rank = 0; uint8_t file = 0; bool operator==(const Position &) const = default; }; struct TranspositionsEntry { int depth; int Eval; }; struct Game { Piece pieces[64]; bool turn = true; // 1 white; 0 black bool whiteCastleKing = false; bool whiteCastleQueen = false; bool blackCastleKing = false; bool blackCastleQueen = false; uint8_t halfMoveClock = 0; uint16_t MoveClock = 0; Position enPassant; bool canEnpassant = false; GameState state = TURN; std::unordered_map ThreeFoldMap; std::unordered_map *Transpositions = nullptr; }; struct Move { Position From; Position To; PieceType promotion = NONEPIECE; bool operator==(const Move &other) const { return From == other.From && To == other.To && promotion == other.promotion; } }; struct UndoMove { Piece movedPiece; Piece capturedPiece; Position from; Position to; bool wasEnPassantCapture = false; Position enPassantCapturedSquare; Piece enPassantCapturedPiece; bool oldTurn; bool oldCanEnpassant; Position oldEnPassant; bool OldWhiteCastleKing; bool OldWhiteCastleQueen; bool OldBlackCastleKing; bool OldBlackCastleQueen; int oldHalfMoveClock; int oldMoveClock; uint64_t ZobristKey; GameState oldState; // castling bool wasCastle = false; bool CastledSide = false; // 0 for queen side, 1 for king side }; Piece createPiece(PieceType type, bool color); int PositionToIndex(Position i); UndoMove MakeMove(Move move, Game *g); void UnMakeMove(UndoMove undo, Game *g); Position FindKing(Game *b, bool white); #endif /* SRC_BOARD_H_ */