13 std::sprintf(sqStr,
"%c%c", (
'a' + fileIdx), (
'1' + rankIdx));
31 }
else if (
IsRQ(promoted) && !
IsBQ(promoted)) {
33 }
else if (!
IsRQ(promoted) &&
IsBQ(promoted)) {
36 std::sprintf(mvStr,
"%c%c%c%c%c",
37 (
'a' + fromFile), (
'1' + fromRank),
38 (
'a' + toFile), (
'1' + toRank),
41 std::sprintf(mvStr,
"%c%c%c%c",
42 (
'a' + fromFile), (
'1' + fromRank),
43 (
'a' + toFile), (
'1' + toRank));
52 if (text[1] >
'8' || text[1] <
'1')
return NOMOVE;
53 if (text[3] >
'8' || text[3] <
'1')
return NOMOVE;
54 if (text[0] >
'h' || text[0] <
'a')
return NOMOVE;
55 if (text[2] >
'h' || text[2] <
'a')
return NOMOVE;
57 const int fromSq =
FR2SQ(text[0] -
'a', text[1] -
'1');
58 const int toSq =
FR2SQ(text[2] -
'a', text[3] -
'1');
65 for (
int i = 0; i < moveList->
count; ++i) {
66 const int moveEnc = moveList->
moves[i].
move;
67 if (
FROMSQ(moveEnc) == fromSq &&
TOSQ(moveEnc) == toSq) {
68 const int promoPiece =
PROMOTED(moveEnc);
69 if (promoPiece !=
EMPTY) {
71 if (
IsRQ(promoPiece) && !
IsBQ(promoPiece) && text[4] ==
'r')
return moveEnc;
72 if (!
IsRQ(promoPiece) &&
IsBQ(promoPiece) && text[4] ==
'b')
return moveEnc;
73 if (
IsRQ(promoPiece) &&
IsBQ(promoPiece) && text[4] ==
'q')
return moveEnc;
74 if (
IsKn(promoPiece) && text[4] ==
'n')
return moveEnc;
84 std::printf(
"MoveList:\n");
85 for (
int i = 0; i < moveList->
count; ++i) {
86 const int moveEnc = moveList->
moves[i].
move;
88 std::printf(
"Move:%d > %s (score:%d)\n", i + 1,
moveToString(moveEnc), score);
90 std::printf(
"MoveList Total %d Moves:\n\n", moveList->
count);
bool isBoardStateValid(const S_BOARD *pos)
Performs a full internal consistency check of the board state.
void generateAllMoves(const S_BOARD *board, S_MOVELIST *moveList)
Generate all pseudo-legal moves for the side to move.
int parseMoveString(char *text, S_BOARD *board)
Parse a move from coordinate notation.
char * moveToString(const int move)
Convert an encoded move to coordinate notation.
char * squareToString(const int square)
Convert a board square index to algebraic notation.
void printMoveList(const S_MOVELIST *moveList)
Print all moves in a move list to stdout.
int rankIndex120[BRD_SQ_NUM]
int fileIndex120[BRD_SQ_NUM]
File and rank lookup tables for each square (120-based).
S_MOVE moves[MAXPOSITIONMOVES]
int SqOnBoard(const int sq)
Checks if a given square index refers to a valid on-board square.