13#pragma GCC diagnostic push
14#pragma GCC diagnostic ignored "-Weffc++"
20 memset(m_fields, 0,
sizeof(m_fields));
28 for (
rank_t iRank = 0; iRank < 8; ++iRank) {
29 auto initRank = [
this](
rank_t iR, std::string
const& rankdata) ->
void {
33 unsigned char c =
static_cast<unsigned char>(rankdata[i++]);
36 }
else if ((c >=
'1') && (c <=
'8')) {
44 initRank(7 - iRank, rowParts[
static_cast<unsigned long>(iRank)]);
47 if (fenParts.size() > 2) {
55 if (fenParts.size() > 3) {
57 if (fenParts[3] ==
"-") {
64 if (fenParts.size() > 4) {
69 if (fenParts.size() > 5) {
71 setPly(
static_cast<plynum_t>((atoi(fenParts[5].c_str()) - 1) * 2));
74 if (fenParts.size() > 1) {
76 if (fenParts[1] ==
"b")
incPly();
91#pragma GCC diagnostic pop
103 for (
rank_t iRank = 0; iRank < 8; ++iRank) {
105 for (
column_t iCol = 0; iCol < 8; ++iCol) {
108 if (iBlanks) strfen +=
static_cast<char>(iBlanks +
'0');
115 if (iBlanks) strfen +=
static_cast<char>(iBlanks +
'0');
116 if (iRank < 7) strfen +=
"/";
125 strfen += castl.size() ? castl :
"-";
128 strfen +=
" " + std::string(
bCase(
getEp())) +
" ";
151 m_boardInfo.s_boardInfo.capturedpiece &= 0x8F;
154 m_boardInfo.s_boardInfo.capturedpiece |= 0x80;
157 m_boardInfo.s_boardInfo.capturedpiece |=
bCase::column(e) << 4;
168 m_boardInfo.s_boardInfo.capturedpiece &= 0x0F;
182 if (!(m_boardInfo.s_boardInfo.flags & f)) {
183 m_boardInfo.s_boardInfo.flags |= f;
192 if (m_boardInfo.s_boardInfo.flags & f) {
193 m_boardInfo.s_boardInfo.flags &= 0x0F & ~f;
213 }
else if (ct == 0) {
219 }
else if (ct == 56) {
255 m_boardInfo.s_boardInfo.whiteKing = ct;
263 m_boardInfo.s_boardInfo.blackKing = ct;
279 for (
case_t iCase = 0; iCase < 64; ++iCase) {
382 }
else if (cf == 7) {
465 }
else if (cf == 63) {
554 m_boardInfo.u_boardInfo = oldBoardInfo.
u_boardInfo;
581 if (newcol != oldcol) {
593 if ((newcol - oldcol) == 2) {
597 }
else if ((newcol - oldcol) == -2) {
606 if (newcol != oldcol) {
618 if ((newcol - oldcol) == 2) {
622 }
else if ((newcol - oldcol) == -2) {
663 m_boardInfo.s_boardInfo.whiteKing = cf;
665 if ((newcol - oldcol) == 2) {
669 }
else if ((newcol - oldcol) == -2) {
678 m_boardInfo.s_boardInfo.blackKing = cf;
680 if ((newcol - oldcol) == 2) {
684 }
else if ((newcol - oldcol) == -2) {
693 m_boardInfo.u_boardInfo = oldBoardInfo.
u_boardInfo;
700 std::stringstream ss;
701 ss << std::nouppercase << std::setfill(
'0')
702 << std::setw(16) << std::hex << m_hash;
union boardInfo boardInfo_t
hashkey_t hashmultiplexer[tPiece::P_SIZE][64]
constexpr hashkey_t HASH_INIT
constexpr hashkey_t HASH_ODDMATERIAL
constexpr hashkey_t HASH_BLACKTOMOVE
This is the main include file, needs to be included before any other include.
constexpr piece_t getPiece(case_t const cf) const
void setCapturedPiece(piece_t p)
void moveBlackKing(case_t const cf, case_t const ct)
constexpr int16_t getMoveNumber() const
boardInfo_t makeBoardMove(column_t const oldcol, rank_t const oldrank, column_t const newcol, rank_t const newrank)
apply move to check if in check only, board to be discarded as it will be in incomplete state,...
void movePiece(case_t const cf, case_t const ct, piece_t const np)
void restorePiece(case_t const cf, piece_t const op)
void setPly50Moves(movenum50_t const p)
boardInfo_t applyBlackMove(bMove const &m)
void moveWhiteKing(case_t const cf, case_t const ct)
constexpr bool hasCastleRights(uint8_t const f) const
boardInfo_t applyWhiteMove(bMove const &m)
void setEp(case_t const e)
set ep case, it will actually be stored as column only rank will be calculated based on side to move ...
void unApplyMove(bMove const &m, boardInfo_t const oldBoardInfo)
exact restoration of basic board using move details
void clearCapturedPiece()
std::string getHashStr() const
virtual boardInfo_t applyMove(bMove const &m)
play game move on board
constexpr case_t getEp() const
void unMakeBoardMove(case_t const &cf, column_t const newcol, rank_t const newrank, boardInfo_t const oldBoardInfo)
undo makeBoardMove, restoring previous situation
void capturePieceOn(piece_t const capturedPiece, case_t const ct)
Clear castle flag if rook captured update piece counter, update hash, clear field.
void clearPiece(case_t const cf)
piece_t setGetPiece(column_t const newcol, rank_t const newrank, piece_t const piece)
piece_t removePiece(column_t const newcol, rank_t const newrank)
void swapPiece(case_t const cf, piece_t const op, piece_t const np)
constexpr movenum50_t getPly50Moves() const
constexpr bool isEpSet() const
constexpr int8_t pieceCount() const
void clearCastleRights(uint8_t const f)
constexpr side_t getColourToMove() const
void setBlackHasCastled()
void calcHash()
Set hash based on board position, also calc pieces Byte 0: bits 4-6 capture count (masked) bit 7 play...
void setPieceCount(int8_t const n)
void setCastleRights(uint8_t const f)
void setWhiteHasCastled()
void setPieceKU(case_t const cf, piece_t const piece)
void setPiece(case_t const cf, piece_t const piece)
void setPly(plynum_t const p)
constexpr piece_t getCapturedPiece() const
constexpr bool isLongCastleMove() const
piece_t getWhitePromotionPiece() const
constexpr rank_t fromrank() const
piece_t getBlackPromotionPiece() const
constexpr bool isCastleMove() const
constexpr column_t tocolumn() const
constexpr bool isEPPossible() const
constexpr bool isCapture() const
constexpr case_t to() const
constexpr bool isPromotion() const
constexpr bool isEPMove() const
constexpr bool isCheck() const
constexpr case_t from() const
position on board, defined as 255 if invalid used primarily to compose a move or a source or destinat...
constexpr column_t column() const
static constexpr case_t coordToCase(column_t const c, rank_t const r)
static cpiece_t getPieceChar(piece_t const piece)
static class member function
constexpr piece_t getPiece() const
std::string alltrim(std::string s, std::string const &delim=" ")
trim left and right spaces or delim from string
std::string to_string(int16_t value)
std::to_string not compatible on Mac OS (Apple LLVM version 5.0) provide generic utility function
stringList const stringSplit(std::string src, std::string const &delim)
Split delimited long string into a vector.
std::vector< std::string > stringList
struct boardInfo::@022254060033317030245227153321374007124317132060 s_boardInfo
uint8_t capturedpiece
4 castling bits, plus incheck flag and capture move
void setCapturedPiece(piece_t p)