95 lines
1.9 KiB
C++
95 lines
1.9 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::AccumulatorPair accPair;
|
|
|
|
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;
|
|
U64 minorKey = 0ULL;
|
|
|
|
std::array<Bitboard, 4> checkZones;
|
|
|
|
void Reset();
|
|
void SetByFen(std::string_view fen);
|
|
std::string GetFen();
|
|
void PrintBoard();
|
|
|
|
void PrintNNUE();
|
|
|
|
void AddMove(Move move);
|
|
void ResetMoves();
|
|
void ListMoves();
|
|
|
|
ACC::BucketPair GetBuckets();
|
|
void ResetAccPair();
|
|
|
|
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);
|
|
};
|