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;
352 int8_t
const ci, int8_t
const ri,
355 int8_t offset = (8 * ri) + ci;
361 if (fromcol < 0 || fromcol > 7)
break;
363 if (fromrank < 0 || fromrank > 7)
break;
369 if (piece == cPiece)
return true;
370 if (piece == cPiece2)
return true;
385 bool canMove =
false;
405 case_t const& cf, int8_t
const ri, int8_t
const ci)
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;
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)
const
496 rank_t newrank = oldrank + ri;
498 bool canMove =
false;
501 if (newcol < 0 || newcol > 7)
return false;
502 if (newrank < 0 || newrank > 7)
return false;
525 case_t const& cf, int8_t
const ri, int8_t
const ci)
const
530 if (newcol < 0 || newcol > 7)
return false;
534 rank_t newrank = oldrank + ri;
535 if (newrank < 0 || newrank > 7)
return false;
586 case_t const& cf, int8_t
const ri, int8_t
const ci,
589 int_fast8_t nMax = 7;
594 while (--nMax >= 0) {
595 if (newcol < 0 || newcol > 7)
return nMoves;
596 if (newrank < 0 || newrank > 7)
return nMoves;
618 case_t const& cf, int8_t
const ri, int8_t
const ci,
621 int_fast8_t nMax = 7;
626 while (--nMax >= 0) {
627 if (newcol < 0 || newcol > 7)
return nMoves;
628 if (newrank < 0 || newrank > 7)
return nMoves;
667 case_t const& cf, int8_t
const ci)
const
670 if (newcol < 0 || newcol > 7)
return false;
684 case_t const& cf, int8_t
const ci)
const
687 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;
797 if (newcol < 0 || newcol > 7)
return 0;
815 if (newcol < 0 || newcol > 7)
return 0;
866 if (newcol < 0 || newcol > 7)
return 0;
884 if (newcol < 0 || newcol > 7)
return 0;
937 if (canPawnMove(b, cf))
return true;
938 if (canPawnCapture(b, cf, -1))
return true;
939 if (canPawnCapture(b, cf, 1))
return true;
941 if (canPawnEPMove(b, cf, -1))
return true;
942 if (canPawnEPMove(b, cf, 1))
return true;
962 if (oldrank == 4 && b.
isEpSet()) {
979 if (canPawnMove(b, cf))
return true;
980 if (canPawnCapture(b, cf, -1))
return true;
981 if (canPawnCapture(b, cf, 1))
return true;
983 if (canPawnEPMove(b, cf, -1))
return true;
984 if (canPawnEPMove(b, cf, 1))
return true;
1004 if (oldrank == 3 && b.
isEpSet()) {
1038 nMoves +=
addMoves(b, cf, -1, 0, ml);
1039 nMoves +=
addMoves(b, cf, 1, 0, ml);
1040 nMoves +=
addMoves(b, cf, 0, -1, ml);
1041 nMoves +=
addMoves(b, cf, 0, 1, ml);
1051 nMoves +=
addMoves(b, cf, -1, 0, ml);
1052 nMoves +=
addMoves(b, cf, 1, 0, ml);
1053 nMoves +=
addMoves(b, cf, 0, -1, ml);
1054 nMoves +=
addMoves(b, cf, 0, 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);
1127 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);
1140 nMoves +=
addMoves(b, cf, 1, 1, ml);
1176 nMoves +=
addMoves(b, cf, 0, -1, ml);
1177 nMoves +=
addMoves(b, cf, 0, 1, ml);
1178 nMoves +=
addMoves(b, cf, 1, -1, ml);
1179 nMoves +=
addMoves(b, cf, 1, 0, ml);
1180 nMoves +=
addMoves(b, cf, 1, 1, ml);
1181 nMoves +=
addMoves(b, cf, -1, -1, ml);
1182 nMoves +=
addMoves(b, cf, -1, 0, ml);
1183 nMoves +=
addMoves(b, cf, -1, 1, ml);
1193 nMoves +=
addMoves(b, cf, 0, -1, ml);
1194 nMoves +=
addMoves(b, cf, 0, 1, ml);
1195 nMoves +=
addMoves(b, cf, 1, -1, ml);
1196 nMoves +=
addMoves(b, cf, 1, 0, ml);
1197 nMoves +=
addMoves(b, cf, 1, 1, ml);
1198 nMoves +=
addMoves(b, cf, -1, -1, ml);
1199 nMoves +=
addMoves(b, cf, -1, 0, ml);
1200 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
static movenum_t addNonCapturePromotionMove(bBasicBoard const &b, case_t const &cf, bMoveList &ml)
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
static movenum_t addNonCapturePawnMove(bBasicBoard const &b, case_t const &cf, bMoveList &ml)
Class static function Test move is possible, single step move non capture move.
static movenum_t addCapturePawnMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml)
bool canMovePreflightCheck(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.
static movenum_t addEPMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml)
Test move is possible, e.p.
static movenum_t addCapturePromotionMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml)
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
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.
static 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)
Class static function 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 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
bool canMovePreflightCheck(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 GenerateMoves(bBasicBoard const &b, case_t const &cf, bMoveList &ml) override
static movenum_t addCapturePromotionMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml)
Test move is possible, single step move capture only move.
static movenum_t addNonCapturePromotionMove(bBasicBoard const &b, case_t const &cf, bMoveList &ml)
Test move is possible, single step move non capture move.
static movenum_t addCapturePawnMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml)
static movenum_t addEPMove(bBasicBoard const &b, case_t const &cf, int8_t const ci, bMoveList &ml)
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
static movenum_t addNonCapturePawnMove(bBasicBoard const &b, case_t const &cf, bMoveList &ml)
Class static function Test move is possible, single step move non capture move.
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)