Chess 0.0.1
A library written in c
Loading...
Searching...
No Matches
piece_type.h File Reference

Defines the chess piece type type and related utility functions for representing and manipulating chess piece types. More...

#include <chess/macros.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Enumerations

enum  ChessPieceType : uint8_t {
  CHESS_PIECE_TYPE_PAWN = 0 ,
  CHESS_PIECE_TYPE_KNIGHT = 1 ,
  CHESS_PIECE_TYPE_BISHOP = 2 ,
  CHESS_PIECE_TYPE_ROOK = 3 ,
  CHESS_PIECE_TYPE_QUEEN = 4 ,
  CHESS_PIECE_TYPE_KING = 5 ,
  CHESS_PIECE_TYPE_NONE = 6
}
 Represents the types of chess pieces. More...
 

Functions

void chess_piece_type_debug (ChessPieceType type)
 Prints a debug representation of the given piece type.
 
bool chess_piece_type_is_valid (ChessPieceType type)
 Checks if the given piece type is valid.
 
size_t chess_piece_type_from_algebraic (ChessPieceType *type, const char *string)
 Parses a piece type from algebraic notation (e.g., "P", "N", ..., "K").
 
size_t chess_piece_type_to_algebraic (ChessPieceType type, char *string, size_t string_size)
 Converts a piece type to algebraic notation (e.g., "P", "N", ..., "K").
 

Detailed Description

Defines the chess piece type type and related utility functions for representing and manipulating chess piece types.

Author
Tarek Saeed
Date
2025-06-14

Enumeration Type Documentation

◆ ChessPieceType

enum ChessPieceType : uint8_t

Represents the types of chess pieces.

Enumerator
CHESS_PIECE_TYPE_PAWN 

Pawn piece type

CHESS_PIECE_TYPE_KNIGHT 

Knight piece type

CHESS_PIECE_TYPE_BISHOP 

Bishop piece type

CHESS_PIECE_TYPE_ROOK 

Rook piece type

CHESS_PIECE_TYPE_QUEEN 

Queen piece type

CHESS_PIECE_TYPE_KING 

King piece type

CHESS_PIECE_TYPE_NONE 

No piece type

Function Documentation

◆ chess_piece_type_debug()

void chess_piece_type_debug ( ChessPieceType  type)

Prints a debug representation of the given piece type.

Parameters
[in]typeThe piece type to print.

◆ chess_piece_type_from_algebraic()

size_t chess_piece_type_from_algebraic ( ChessPieceType type,
const char *  string 
)

Parses a piece type from algebraic notation (e.g., "P", "N", ..., "K").

Parameters
[out]typePointer to store the parsed piece type.
[in]stringThe string containing the algebraic notation.
Returns
The number of characters read if successful, 0 otherwise.

◆ chess_piece_type_is_valid()

bool chess_piece_type_is_valid ( ChessPieceType  type)

Checks if the given piece type is valid.

Parameters
[in]typeThe piece type to check.
Returns
true if the piece type is valid, false otherwise.

◆ chess_piece_type_to_algebraic()

size_t chess_piece_type_to_algebraic ( ChessPieceType  type,
char *  string,
size_t  string_size 
)

Converts a piece type to algebraic notation (e.g., "P", "N", ..., "K").

Parameters
[in]typeThe piece type to convert.
[out]stringThe buffer to store the algebraic notation.
[in]string_sizeThe size of the output buffer.
Returns
The number of characters written.