Chess Engine
C++ chess engine with movegen, bitboards, and Arduino-friendly docs
Loading...
Searching...
No Matches
notation.cpp File Reference
#include <cstdio>
#include "defs.h"
#include "../move/move_generator.h"
#include "notation.h"
#include "setup.h"
Include dependency graph for notation.cpp:

Go to the source code of this file.

Functions

char * squareToString (const int square)
 Convert a board square index to algebraic notation.
char * moveToString (const int move)
 Convert an encoded move to coordinate notation.
int parseMoveString (char *text, S_BOARD *board)
 Parse a move from coordinate notation.
void printMoveList (const S_MOVELIST *moveList)
 Print all moves in a move list to stdout.

Function Documentation

◆ moveToString()

char * moveToString ( int move)

Convert an encoded move to coordinate notation.

Parameters
moveEncoded move integer.
Returns
Pointer to a static string containing the move (e.g., "e2e4", "e7e8q").
Note
This uses a static buffer and is not thread-safe.

Definition at line 17 of file notation.cpp.

References fileIndex120, FROMSQ, IsBQ, IsKn, IsRQ, PROMOTED, rankIndex120, and TOSQ.

Referenced by PerftTest(), and printMoveList().

Here is the caller graph for this function:

◆ parseMoveString()

int parseMoveString ( char * ptrChar,
S_BOARD * pos )

Parse a move from coordinate notation.

Parameters
ptrCharPointer to a string containing the move (e.g., "e2e4", "e7e8q").
posPointer to the current board state.
Returns
Encoded move integer, or NOMOVE if invalid.

Definition at line 48 of file notation.cpp.

References ASSERT, S_MOVELIST::count, EMPTY, FR2SQ, FROMSQ, generateAllMoves(), isBoardStateValid(), IsBQ, IsKn, IsRQ, S_MOVE::move, S_MOVELIST::moves, NOMOVE, PROMOTED, SqOnBoard(), and TOSQ.

Here is the call graph for this function:

◆ printMoveList()

void printMoveList ( const S_MOVELIST * list)

Print all moves in a move list to stdout.

Parameters
listPointer to the move list to print.

Definition at line 83 of file notation.cpp.

References S_MOVELIST::count, S_MOVE::move, S_MOVELIST::moves, moveToString(), and S_MOVE::score.

Here is the call graph for this function:

◆ squareToString()

char * squareToString ( int sq)

Convert a board square index to algebraic notation.

Parameters
sqBoard square index (0–119 in mailbox 120 format).
Returns
Pointer to a static string containing the square (e.g., "e4").
Note
This uses a static buffer and is not thread-safe.

Definition at line 7 of file notation.cpp.

References fileIndex120, and rankIndex120.

Referenced by LegalMovesFrom().

Here is the caller graph for this function: