#pragma once #include #include "bitboard.h" #include "types.h" #include "move.h" #include "accumulator.h" constexpr int nullPieceType = 100; constexpr int noEPTarget = -1; constexpr int MAX_MOVES = 218; class Board { public: Board() { SetByFen(StartingFen); } std::array mailbox; std::array pieces; std::array colors; Bitboard occupied; std::array pinned; Bitboard checkers; ACC::Update accUpdate; bool mirroredWhite = false; bool mirroredBlack = false; std::array pieceThreats; std::array colorThreats; std::array moveList; int currentMoveIndex = 0; bool sideToMove = White; uint8_t castlingRights = 0; int enPassantTarget = noEPTarget; short positionIndex = 0; int halfMoves = 0; int fullMoves = 1; U64 hashKey = 0ULL; U64 pawnKey = 0ULL; U64 nonPawnKey = 0ULL; U64 majorKey = 0ULL; std::array checkZones; void Reset(); void SetByFen(std::string_view fen); std::string GetFen(); void PrintBoard(); void PrintNNUE(bool full = false); void AddMove(Move move); void ResetMoves(); void ListMoves(); ACC::BucketPair GetBuckets(); void RefreshAccumulator(ACC::AccumulatorPair& out) const; void UpdateAccumulator(ACC::AccStack& stack, int ply); void RefreshPerspective(ACC::FinnyTable& finny, bool perspective, ACC::Accumulator& out) const; void ApplyDeltaPerspective(bool perspective, ACC::Accumulator& dst, const ACC::Accumulator& src) const; void MarkAccumulatorDirty() { accUpdate.setRefresh(); } int GetPieceType(int square); int GetPieceColor(int square); bool InCheck(); void SetPiece(int piece, int square, bool color); void RemovePiece(int piece, int square, bool color); void Promote(int square, int pieceType, int color, bool isCapture); void MakeMove(Move move); bool InPossibleZug(); Bitboard AttacksTo(int square, Bitboard occupancy); bool IsSquareThreatened(bool side, int square); Bitboard CalcCheckers(); Bitboard CalcPinned(bool color); void CalcCheckZones(); bool GivesDirectCheck(Move &move); bool IsLegal(Move &move); bool IsPseudoLegal(Move &move); };