147 if (!p)
return false;
155 if (!p)
return false;
292 piece_t const cPiece, int8_t
const ri, int8_t
const ci)
const
309 int8_t
const ri, int8_t
const ci)
const
315 for (int8_t i = 0; i < 7; i++) {
317 if (newrank < 0 || newrank > 7)
return false;
318 if (newcol < 0 || newcol > 7)
return false;
322 if (piece == cPiece)
return true;
323 if (piece == cPiece2)
return true;
327 newrank += ri; newcol += ci;
341 piece_t const cPiece, int8_t
const ci)
const
345 for (int8_t i = 0; i < 5; i++) {
347 if (newcol < 0 || newcol > 7)
return false;
351 if (p == cPiece)
return true;
365 int8_t
const ri, int8_t
const ci,
bMoveList& ml)
const
370 if (newcol < 0 || newcol > 7)
return 0;
371 if (newrank < 0 || newrank > 7)
return 0;
389 side_t const side,
int nMax,
390 int8_t
const ri, int8_t
const ci,
bMoveList& ml)
const
396 while (--nMax >= 0) {
397 if (newcol < 0 || newcol > 7)
return nMoves;
398 if (newrank < 0 || newrank > 7)
return nMoves;
450 int8_t
const ri, int8_t
const ci,
bMoveList& ml)
const
454 if (newcol < 0 || newcol > 7)
return 0;
487 int8_t
const ri, int8_t
const ci,
bMoveList& ml)
const
491 if (newcol < 0 || newcol > 7)
return 0;
510 int8_t
const ri, int8_t
const ci,
bMoveList& ml)
const
538 nMoves +=
addEPMove(b, cf, side, 1, -1, ml);
540 nMoves +=
addEPMove(b, cf, side, 1, 1, ml);
564 nMoves +=
addEPMove(b, cf, side, -1, -1, ml);
566 nMoves +=
addEPMove(b, cf, side, -1, 1, ml);
578 nMoves +=
addMoves(b, cf, side, 7, -1, 0, ml);
579 nMoves +=
addMoves(b, cf, side, 7, 1, 0, ml);
580 nMoves +=
addMoves(b, cf, side, 7, 0, -1, ml);
581 nMoves +=
addMoves(b, cf, side, 7, 0, 1, ml);
591 nMoves +=
addMove(b, cf, side, 1, 2, ml);
592 nMoves +=
addMove(b, cf, side, 1, -2, ml);
593 nMoves +=
addMove(b, cf, side, 2, 1, ml);
594 nMoves +=
addMove(b, cf, side, -2, 1, ml);
595 nMoves +=
addMove(b, cf, side, -1, 2, ml);
596 nMoves +=
addMove(b, cf, side, -1, -2, ml);
597 nMoves +=
addMove(b, cf, side, 2, -1, ml);
598 nMoves +=
addMove(b, cf, side, -2, -1, ml);
608 nMoves +=
addMoves(b, cf, side, 7, -1, -1, ml);
609 nMoves +=
addMoves(b, cf, side, 7, 1, -1, ml);
610 nMoves +=
addMoves(b, cf, side, 7, -1, 1, ml);
611 nMoves +=
addMoves(b, cf, side, 7, 1, 1, ml);
621 nMoves +=
addMoves(b, cf, side, 7, 0, -1, ml);
622 nMoves +=
addMoves(b, cf, side, 7, 0, 1, ml);
623 nMoves +=
addMoves(b, cf, side, 7, 1, -1, ml);
624 nMoves +=
addMoves(b, cf, side, 7, 1, 0, ml);
625 nMoves +=
addMoves(b, cf, side, 7, 1, 1, ml);
626 nMoves +=
addMoves(b, cf, side, 7, -1, -1, ml);
627 nMoves +=
addMoves(b, cf, side, 7, -1, 0, ml);
628 nMoves +=
addMoves(b, cf, side, 7, -1, 1, ml);
638 nMoves +=
addMove(b, cf, side, 0, -1, ml);
639 nMoves +=
addMove(b, cf, side, 0, 1, ml);
640 nMoves +=
addMove(b, cf, side, 1, -1, ml);
641 nMoves +=
addMove(b, cf, side, 1, 0, ml);
642 nMoves +=
addMove(b, cf, side, 1, 1, ml);
643 nMoves +=
addMove(b, cf, side, -1, -1, ml);
644 nMoves +=
addMove(b, cf, side, -1, 0, ml);
645 nMoves +=
addMove(b, cf, side, -1, 1, ml);
This is the main include file, needs to be included before any other include.
bool canCastle(uint8_t const f) const
piece_t getPiece(case_t const bc) const
1 for white, 2 for black
piece_t getPieceCtl(column_t const iColumn, rank_t const iRank) const
retrieve piece with bounds checking, return field empty in case of out of bounds
bool isFieldEmpty(case_t const bc) const
void setCastleMove(uint16_t f)
int GenerateMoves(bBoard const &b, case_t const &cf, bMoveList &ml, side_t const side) final
int GenerateMoves(bBoard const &b, case_t const &cf, bMoveList &ml, side_t const side) final
int GenerateMoves(bBoard const &b, case_t const &cf, bMoveList &ml, side_t const side) final
bool isAttacked(bBoard const &b, case_t const &cf) const override
static constexpr case_t coordToCase(column_t const c, rank_t const r)
bool kingSeesRook(bBoard const &b, case_t const &cf, piece_t const cPiece, int8_t const ci) const
Return true if king sees rook of own colour.
int GenerateMoves(bBoard const &b, case_t const &cf, bMoveList &ml, side_t const side) override
int GenerateMoves(bBoard const &b, case_t const &cf, bMoveList &ml, side_t const side) final
uint8_t addMoveIfValid(bBoard const &b, bMove const &m, side_t const side)
Only add move to movelist if valid.
uint8_t addPromotionIfValid(bBoard const &b, bMove const &m, side_t const side)
Only add move to movelist if valid.
int addNonCapturePromotionMove(bBoard const &b, case_t const &cf, side_t const side, int8_t const ri, bMoveList &ml) const
Test move is possible, single step move non capture move.
int addNonCapturePawnMove(bBoard const &b, case_t const &cf, side_t const side, int8_t const ri, bMoveList &ml) const
Test move is possible, single step move non capture move.
int addNonCaptureDoublePawnMove(bBoard const &b, case_t const &cf, side_t const side, int8_t const ri, bMoveList &ml) const
int addEPMove(bBoard const &b, case_t const &cf, side_t const side, int8_t const ri, int8_t const ci, bMoveList &ml) const
Test move is possible, e.p.
int addCapturePawnMove(bBoard const &b, case_t const &cf, side_t const side, int8_t const ri, int8_t const ci, bMoveList &ml) const
int addCapturePromotionMove(bBoard const &b, case_t const &cf, side_t const side, int8_t const ri, int8_t const ci, bMoveList &ml) const
Test move is possible, single step move capture only move.
bool isAttackedByPiece(bBoard const &b, case_t const &cf, piece_t const cPiece, int8_t const ri, int8_t const ci) const
Return true if position is attacked by opponent respecting move offsets.
bool isAttackedBySlider(bBoard const &b, case_t const &cf, piece_t const cPiece, piece_t const cPiece2, int8_t const ri, int8_t const ci) const
Return true if position is attacked by opponent respecting move offsets.
int addMove(bBoard const &b, case_t const &cf, side_t const side, int8_t const ri, int8_t const ci, bMoveList &ml) const
Check for in-check position, single step move used for King and Knight.
static bool isOwnColour(side_t const s, piece_t const p)
static class member function
static bPiece * getPieceClass(piece_t const piece)
static class member function
static cpiece_t getPieceChar(piece_t const p)
static class member function
int addMoves(bBoard const &b, case_t const &cf, side_t const side, int nMax, int8_t const ri, int8_t const ci, bMoveList &ml) const
Add moves for Queen, Rook and Bishop.
static bool isOpponent(side_t const s, piece_t const p)
static class member function
static const std::string getPieceStrUpper(piece_t const piece)
static class member function
int GenerateMoves(bBoard const &b, case_t const &cf, bMoveList &ml, side_t const side) final
int GenerateMoves(bBoard const &b, case_t const &cf, bMoveList &ml, side_t const side) final
int GenerateMoves(bBoard const &b, case_t const &cf, bMoveList &ml, side_t const side) final
int GenerateMoves(bBoard const &b, case_t const &cf, bMoveList &ml, side_t const side) final
bool isAttacked(bBoard 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...
Allow index mapper for char values of piece into int in 1-12 range to reduce space and easy initialis...
static bPiece * pieceinstances[tPiece::P_SIZE]
static piece_t bPieceIndex[128]
static cpiece_t bPieceMapper[tPiece::P_SIZE]
constexpr uint16_t LONG_CASTLE
constexpr uint16_t SHORT_CASTLE