Files
Eleanor/source/board.h
T

99 lines
2.3 KiB
C++

#pragma once
#include <array>
#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<int, 64> mailbox;
std::array<Bitboard, 6> pieces;
std::array<Bitboard, 2> colors;
Bitboard occupied;
std::array<Bitboard, 2> pinned;
Bitboard checkers;
ACC::Update accUpdate;
bool mirroredWhite = false;
bool mirroredBlack = false;
std::array<Bitboard, 6> pieceThreats;
std::array<Bitboard, 2> colorThreats;
std::array<Move, MAX_MOVES> 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<Bitboard, 4> 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);
};