|
Chess 0.0.1
A library written in c
|
Defines the chess piece type and related utility functions for representing and manipulating chess pieces. More...
#include <chess/color.h>#include <chess/macros.h>#include <chess/piece_type.h>#include <stdbool.h>#include <stdint.h>Go to the source code of this file.
Enumerations | |
| enum | ChessPiece : uint8_t { CHESS_PIECE_WHITE_PAWN = CHESS_COLOR_WHITE << 3U | CHESS_PIECE_TYPE_PAWN , CHESS_PIECE_WHITE_KNIGHT = CHESS_COLOR_WHITE << 3U | CHESS_PIECE_TYPE_KNIGHT , CHESS_PIECE_WHITE_BISHOP = CHESS_COLOR_WHITE << 3U | CHESS_PIECE_TYPE_BISHOP , CHESS_PIECE_WHITE_ROOK = CHESS_COLOR_WHITE << 3U | CHESS_PIECE_TYPE_ROOK , CHESS_PIECE_WHITE_QUEEN = CHESS_COLOR_WHITE << 3U | CHESS_PIECE_TYPE_QUEEN , CHESS_PIECE_WHITE_KING = CHESS_COLOR_WHITE << 3U | CHESS_PIECE_TYPE_KING , CHESS_PIECE_BLACK_PAWN = CHESS_COLOR_BLACK << 3U | CHESS_PIECE_TYPE_PAWN , CHESS_PIECE_BLACK_KNIGHT = CHESS_COLOR_BLACK << 3U | CHESS_PIECE_TYPE_KNIGHT , CHESS_PIECE_BLACK_BISHOP = CHESS_COLOR_BLACK << 3U | CHESS_PIECE_TYPE_BISHOP , CHESS_PIECE_BLACK_ROOK = CHESS_COLOR_BLACK << 3U | CHESS_PIECE_TYPE_ROOK , CHESS_PIECE_BLACK_QUEEN = CHESS_COLOR_BLACK << 3U | CHESS_PIECE_TYPE_QUEEN , CHESS_PIECE_BLACK_KING = CHESS_COLOR_BLACK << 3U | CHESS_PIECE_TYPE_KING , CHESS_PIECE_NONE = CHESS_COLOR_NONE << 3U | CHESS_PIECE_TYPE_NONE } |
Functions | |
| void | chess_piece_debug (ChessPiece piece) |
| Prints a debug representation of the given piece. | |
| bool | chess_piece_is_valid (ChessPiece piece) |
| Checks if the given piece is valid. | |
| ChessPiece | chess_piece_new (ChessColor color, ChessPieceType type) |
| Creates a piece from a color and piece type. | |
| ChessColor | chess_piece_color (ChessPiece piece) |
| Gets the color of the given piece. | |
| ChessPieceType | chess_piece_type (ChessPiece piece) |
| Gets the type of the given piece. | |
| size_t | chess_piece_from_algebraic (ChessPiece *piece, const char *string) |
| Parses a piece from algebraic notation (e.g., "P", "N", ..., "K", "p", "n", ..., "k"). | |
| size_t | chess_piece_to_algebraic (ChessPiece piece, char *string, size_t string_size) |
| Converts a piece to algebraic notation (e.g., "P", "N", ..., "K", "p", "n", ..., "k"). | |
Defines the chess piece type and related utility functions for representing and manipulating chess pieces.
| enum ChessPiece : uint8_t |
| ChessColor chess_piece_color | ( | ChessPiece | piece | ) |
Gets the color of the given piece.
| [in] | piece | The piece. |
| void chess_piece_debug | ( | ChessPiece | piece | ) |
Prints a debug representation of the given piece.
| [in] | piece | The piece to print. |
| size_t chess_piece_from_algebraic | ( | ChessPiece * | piece, |
| const char * | string | ||
| ) |
Parses a piece from algebraic notation (e.g., "P", "N", ..., "K", "p", "n", ..., "k").
| [out] | piece | Pointer to store the parsed piece. |
| [in] | string | The string containing the algebraic notation. |
| bool chess_piece_is_valid | ( | ChessPiece | piece | ) |
Checks if the given piece is valid.
| [in] | piece | The piece to check. |
| ChessPiece chess_piece_new | ( | ChessColor | color, |
| ChessPieceType | type | ||
| ) |
Creates a piece from a color and piece type.
| [in] | color | The color of the piece. |
| [in] | type | The type of the piece. |
| size_t chess_piece_to_algebraic | ( | ChessPiece | piece, |
| char * | string, | ||
| size_t | string_size | ||
| ) |
Converts a piece to algebraic notation (e.g., "P", "N", ..., "K", "p", "n", ..., "k").
| [in] | piece | The piece to convert. |
| [out] | string | The buffer to store the algebraic notation. |
| [in] | string_size | The size of the output buffer. |
| ChessPieceType chess_piece_type | ( | ChessPiece | piece | ) |
Gets the type of the given piece.
| [in] | piece | The piece. |