93 for (
case_t iCase = 0; iCase < 64; ++iCase) {
98 for (
case_t bit = 0; bit < 64; ++bit) {
105 for (
case_t bit = 0; bit < 64; ++bit) {
144 if (newcol < 0 || newcol > 7)
return 0;
145 if (newrank < 0 || newrank > 7)
return 0;
166#pragma GCC diagnostic push
167#pragma GCC diagnostic ignored "-Wswitch-enum"
204#pragma GCC diagnostic pop
233 if (!p)
return false;
241 if (!p)
return false;
249 if (!p)
return false;
256 if (!p)
return false;
351 int8_t
const ci, int8_t
const ri,
354 int8_t offset = 8 * ri + ci;
360 if (fromcol < 0 || fromcol > 7)
break;
362 if (fromrank < 0 || fromrank > 7)
break;
368 if (piece == cPiece)
return true;
369 if (piece == cPiece2)
return true;
384 bool canMove =
false;
404 case_t const& cf, int8_t
const ri, int8_t
const ci,
405 uint_fast8_t nMax)
const
411 rank_t newrank = oldrank + ri;
413 bool canMove =
false;
416 if (newcol < 0 || newcol > 7)
return false;
417 if (newrank < 0 || newrank > 7)
return false;
429 }
while (--nMax > 0);
440 case_t const& cf, int8_t
const ri, int8_t
const ci)
const
445 if (newcol < 0 || newcol > 7)
return false;
449 rank_t newrank = oldrank + ri;
450 if (newrank < 0 || newrank > 7)
return false;
470 bool canMove =
false;
490 case_t const& cf, int8_t
const ri, int8_t
const ci,
491 uint_fast8_t nMax)
const
497 rank_t newrank = oldrank + ri;
499 bool canMove =
false;
502 if (newcol < 0 || newcol > 7)
return false;
503 if (newrank < 0 || newrank > 7)
return false;
515 }
while (--nMax > 0);
526 case_t const& cf, int8_t
const ri, int8_t
const ci)
const
531 if (newcol < 0 || newcol > 7)
return false;
535 rank_t newrank = oldrank + ri;
536 if (newrank < 0 || newrank > 7)
return false;
587 case_t const& cf, int8_t
const ri, int8_t
const ci,
590 int_fast8_t nMax = 7;
595 while (--nMax >= 0) {
596 if (newcol < 0 || newcol > 7)
return nMoves;
597 if (newrank < 0 || newrank > 7)
return nMoves;
619 case_t const& cf, int8_t
const ri, int8_t
const ci,
622 int_fast8_t nMax = 7;
627 while (--nMax >= 0) {
628 if (newcol < 0 || newcol > 7)
return nMoves;
629 if (newrank < 0 || newrank > 7)
return nMoves;
668 case_t const& cf, int8_t
const ci)
const
671 if (newcol < 0 || newcol > 7)
return false;
685 case_t const& cf, int8_t
const ci)
const
688 if (newcol < 0 || newcol > 7)
return false;
739 case_t const& cf, int8_t
const ci)
const
742 if (newcol < 0 || newcol > 7)
return false;
756 case_t const& cf, int8_t
const ci)
const
759 if (newcol < 0 || newcol > 7)
return false;
796 if (newcol < 0 || newcol > 7)
return 0;
814 if (newcol < 0 || newcol > 7)
return 0;
865 if (newcol < 0 || newcol > 7)
return 0;
883 if (newcol < 0 || newcol > 7)
return 0;
936 if (canPawnMove(b, cf))
return true;
937 if (canPawnCapture(b, cf, -1))
return true;
938 if (canPawnCapture(b, cf, 1))
return true;
940 if (canPawnEPMove(b, cf, -1))
return true;
941 if (canPawnEPMove(b, cf, 1))
return true;
961 if (oldrank == 4 && b.
isEpSet()) {
978 if (canPawnMove(b, cf))
return true;
979 if (canPawnCapture(b, cf, -1))
return true;
980 if (canPawnCapture(b, cf, 1))
return true;
982 if (canPawnEPMove(b, cf, -1))
return true;
983 if (canPawnEPMove(b, cf, 1))
return true;
1003 if (oldrank == 3 && b.
isEpSet()) {
1037 nMoves +=
addMoves(b, cf, -1, 0, ml);
1038 nMoves +=
addMoves(b, cf, 1, 0, ml);
1039 nMoves +=
addMoves(b, cf, 0, -1, ml);
1040 nMoves +=
addMoves(b, cf, 0, 1, ml);
1050 nMoves +=
addMoves(b, cf, -1, 0, ml);
1051 nMoves +=
addMoves(b, cf, 1, 0, ml);
1052 nMoves +=
addMoves(b, cf, 0, -1, ml);
1053 nMoves +=
addMoves(b, cf, 0, 1, ml);
1123 nMoves +=
addMoves(b, cf, -1, -1, ml);
1124 nMoves +=
addMoves(b, cf, 1, -1, ml);
1125 nMoves +=
addMoves(b, cf, -1, 1, ml);
1126 nMoves +=
addMoves(b, cf, 1, 1, ml);
1136 nMoves +=
addMoves(b, cf, -1, -1, ml);
1137 nMoves +=
addMoves(b, cf, 1, -1, ml);
1138 nMoves +=
addMoves(b, cf, -1, 1, ml);
1139 nMoves +=
addMoves(b, cf, 1, 1, ml);
1175 nMoves +=
addMoves(b, cf, 0, -1, ml);
1176 nMoves +=
addMoves(b, cf, 0, 1, ml);
1177 nMoves +=
addMoves(b, cf, 1, -1, ml);
1178 nMoves +=
addMoves(b, cf, 1, 0, ml);
1179 nMoves +=
addMoves(b, cf, 1, 1, ml);
1180 nMoves +=
addMoves(b, cf, -1, -1, ml);
1181 nMoves +=
addMoves(b, cf, -1, 0, ml);
1182 nMoves +=
addMoves(b, cf, -1, 1, ml);
1192 nMoves +=
addMoves(b, cf, 0, -1, ml);
1193 nMoves +=
addMoves(b, cf, 0, 1, ml);
1194 nMoves +=
addMoves(b, cf, 1, -1, ml);
1195 nMoves +=
addMoves(b, cf, 1, 0, ml);
1196 nMoves +=
addMoves(b, cf, 1, 1, ml);
1197 nMoves +=
addMoves(b, cf, -1, -1, ml);
1198 nMoves +=
addMoves(b, cf, -1, 0, ml);
1199 nMoves +=
addMoves(b, cf, -1, 1, ml);
union boardInfo boardInfo_t
This is the main include file, needs to be included before any other include.
std::bitset< 64 > boardbitmap_t
constexpr piece_t getPiece(case_t const cf) 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,...
boardInfo_t applyBlackMove(bMove const &m)
constexpr bool isFieldEmpty(case_t const cf) const
constexpr bool hasCastleRights(uint8_t const f) const
boardInfo_t applyWhiteMove(bMove const &m)
void unApplyMove(bMove const &m, boardInfo_t const oldBoardInfo)
exact restoration of basic board using move details
constexpr case_t getBlackKingPos() const
void unMakeBoardMove(case_t const &cf, column_t const newcol, rank_t const newrank, boardInfo_t const oldBoardInfo)
undo makeBoardMove, restoring previous situation
constexpr case_t getWhiteKingPos() const
constexpr bool isEpSet() const
constexpr column_t getEpColumn() const
void setShortCastleMove()
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
movenum_t addEPMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml) const
Test move is possible, e.p.
movenum_t addNonCapturePawnMove(bBasicBoard const &b, case_t const &cf, bMoveList &ml) const
Test move is possible, single step move non capture move.
movenum_t addCapturePawnMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml) const
movenum_t addCapturePromotionMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml) const
movenum_t addNonCapturePromotionMove(bBasicBoard const &b, case_t const &cf, bMoveList &ml) const
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
check if there is at least one move possible currently, relies on full move generation for pawn
bool canMovePreflightCheck(bBasicBoard &b, case_t const &cf, case_t const &ct) const override
Check if any could be added by just checking there.
bool isAttacked(bBasicBoard const &b, case_t const &cf) const override
bool canPawnMovePreflightCheck(bBasicBoard &b, case_t const &cf, int8_t const ri, int8_t const ci) const override
Check if pawn move could be added by just checking there is not check, case of possible promotion.
movenum_t addMoves(bBasicBoard const &b, case_t const &cf, int8_t const ri, int8_t const ci, bMoveList &ml) const override
movenum_t addMove(bBasicBoard const &b, case_t const &cf, case_t const &ct, bMoveList &ml) const override
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
constexpr rank_t rank() const
static constexpr boardbitmap_t caseToBit(case_t const cf)
constexpr column_t column() const
static constexpr case_t coordToCase(column_t const c, rank_t const r)
movenum_t addBlackMoveIfValid(bBasicBoard const &b, bMove &m)
Only add move to movelist if valid.
movenum_t addBlackPromotionIfValid(bBasicBoard const &b, bMove &m)
Only add move to movelist if valid.
movenum_t addWhiteMoveIfValid(bBasicBoard const &b, bMove &m)
Only add move to movelist if valid.
movenum_t addWhitePromotionIfValid(bBasicBoard const &b, bMove &m)
Only add move to movelist if valid.
bool isAttackedBySlider(bBasicBoard const &b, case_t cf, column_t fromcol, rank_t fromrank, int8_t const ci, int8_t const ri, piece_t const cPiece, piece_t const cPiece2) const
Return true if position is attacked by opponent respecting move offsets.
static cpiece_t getPieceChar(piece_t const piece)
static class member function
static bPiece * getPieceClass(piece_t const piece)
static class member function
constexpr piece_t getPiece() const
static bool isOpponent(side_t const s, piece_t const piece)
static class member function
static bool isOwnColour(side_t const s, piece_t const piece)
static class member function
static bool isBlackPiece(piece_t const p)
static class member function
static bool isWhitePiece(piece_t const p)
static class member function
static const std::string getPieceStrUpper(piece_t const piece)
static class member function
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
movenum_t addNonCapturePawnMove(bBasicBoard const &b, case_t const &cf, bMoveList &ml) const
Test move is possible, single step move non capture move.
movenum_t addCapturePromotionMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml) const
Test move is possible, single step move capture only move.
movenum_t addCapturePawnMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml) const
movenum_t addEPMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml) const
Test move is possible, e.p.
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
check if there is at least one move possible currently, relies on full move generation for pawn
movenum_t addNonCapturePromotionMove(bBasicBoard const &b, case_t const &cf, bMoveList &ml) const
Test move is possible, single step move non capture move.
bool canPawnMovePreflightCheck(bBasicBoard &b, case_t const &cf, int8_t const ri, int8_t const ci) const override
Check if pawn move could be added by just checking there is not check, case of possible promotion.
movenum_t addMove(bBasicBoard const &b, case_t const &cf, case_t const &ct, bMoveList &ml) const override
Check for in-check position, used for King and Knight.
bool canMovePreflightCheck(bBasicBoard &b, case_t const &cf, case_t const &ct) const override
Check if any could be added by just checking there.
bool isAttacked(bBasicBoard const &b, case_t const &cf) const override
Check if piece on position is attacked, start with piece always on board and then with pieces with gr...
movenum_t addMoves(bBasicBoard const &b, case_t const &cf, int8_t const ri, int8_t const ci, bMoveList &ml) const override
Add moves for Queen, Rook and Bishop.
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
bool hasValidMovePreflightCheck(bBasicBoard &b, case_t const &cf) override
movenum_t GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
Allow index mapper for char values of piece into int in 1-12 range to reduce space and easy initialis...
static boardbitmap_t kingmoves[64]
static bPiece * pieceinstances[tPiece::P_SIZE]
static case_t knightarray[64][9]
static boardbitmap_t knightmoves[64]
bBlackKing const * cBlackKingClass
static piece_t bPieceIndex[128]
static case_t kingarray[64][9]
bWhiteKing const * cWhiteKingClass
static cpiece_t bPieceMapper[tPiece::P_SIZE]
static boardbitmap_t destinationbits_knight(case_t const iCase)
static boardbitmap_t destinationbits_king(case_t const iCase)
static boardbitmap_t destinationbits(case_t const iCase, int8_t const ri, int8_t const ci)