Chess Engine
C++ chess engine with movegen, bitboards, and Arduino-friendly docs
Loading...
Searching...
No Matches
interactive_helpers.h File Reference
#include <cstddef>
#include "../defs.h"
#include "../board/board.h"
Include dependency graph for interactive_helpers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int ParseSquare2 (const char *s)
 Parse "e2" style coordinate into a 120-based square index.
int ParsePromotionPiece (char c, int side)
 Map promotion char ('q','r','b','n') to a piece code for the given side. Case-insensitive. Returns EMPTY if none/unknown.
int LegalMovesFrom (S_BOARD *pos, int from, int outMoves[], char labels[][8], int maxOut)
 Build list of legal moves that originate from from.
int MatchDestinationMove (S_BOARD *pos, int from, const char *destStr, const int legalMoves[], int nMoves)
 Resolve a destination string ("e4", "e8=Q", "e8q") to a move.

Function Documentation

◆ LegalMovesFrom()

int LegalMovesFrom ( S_BOARD * pos,
int from,
int outMoves[],
char labels[][8],
int maxOut )

Build list of legal moves that originate from from.

Parameters
posBoard state.
from120-based from-square.
outMovesOutput array of encoded moves.
labelsOutput labels (e.g., "e4", "e8=Q"), each [8].
maxOutCapacity of outMoves/labels.
Returns
Count of legal moves written (<= maxOut).

Definition at line 31 of file interactive_helpers.cpp.

References bB, bN, bQ, bR, S_MOVELIST::count, EMPTY, FROMSQ, generateAllMoves(), makeMove(), S_MOVE::move, S_MOVELIST::moves, PROMOTED, squareToString(), takeMove(), TOSQ, TRUE, wB, wN, wQ, and wR.

Here is the call graph for this function:

◆ MatchDestinationMove()

int MatchDestinationMove ( S_BOARD * pos,
int from,
const char * destStr,
const int legalMoves[],
int nMoves )

Resolve a destination string ("e4", "e8=Q", "e8q") to a move.

Returns
Encoded move or NOMOVE if none matches.

Definition at line 64 of file interactive_helpers.cpp.

References bQ, EMPTY, FROMSQ, NOMOVE, ParsePromotionPiece(), ParseSquare2(), PROMOTED, S_BOARD::side, TOSQ, WHITE, and wQ.

Here is the call graph for this function:

◆ ParsePromotionPiece()

int ParsePromotionPiece ( char c,
int side )

Map promotion char ('q','r','b','n') to a piece code for the given side. Case-insensitive. Returns EMPTY if none/unknown.

Definition at line 19 of file interactive_helpers.cpp.

References bB, bN, bQ, bR, EMPTY, wB, WHITE, wN, wQ, and wR.

Referenced by MatchDestinationMove().

Here is the caller graph for this function:

◆ ParseSquare2()

int ParseSquare2 ( const char * s)

Parse "e2" style coordinate into a 120-based square index.

Returns
FR2SQ(file,rank) on success; -1 on bad input.

Definition at line 10 of file interactive_helpers.cpp.

References FR2SQ.

Referenced by MatchDestinationMove().

Here is the caller graph for this function: