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

Defines the chess castling rights type and related utility functions for representing and manipulating chess castling rights. More...

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

Go to the source code of this file.

Enumerations

enum  ChessCastlingRights : uint8_t {
  CHESS_CASTLING_RIGHTS_NONE = 0U ,
  CHESS_CASTLING_RIGHTS_WHITE_KINGSIDE = 1U << 0U ,
  CHESS_CASTLING_RIGHTS_WHITE_QUEENSIDE = 1U << 1U ,
  CHESS_CASTLING_RIGHTS_BLACK_KINGSIDE = 1U << 2U ,
  CHESS_CASTLING_RIGHTS_BLACK_QUEENSIDE = 1U << 3U ,
  CHESS_CASTLING_RIGHTS_WHITE = CHESS_CASTLING_RIGHTS_WHITE_KINGSIDE | CHESS_CASTLING_RIGHTS_WHITE_QUEENSIDE ,
  CHESS_CASTLING_RIGHTS_BLACK = CHESS_CASTLING_RIGHTS_BLACK_KINGSIDE | CHESS_CASTLING_RIGHTS_BLACK_QUEENSIDE ,
  CHESS_CASTLING_RIGHTS_ALL = CHESS_CASTLING_RIGHTS_WHITE | CHESS_CASTLING_RIGHTS_BLACK
}
 Represents the castling rights in a chess game. More...
 

Functions

void chess_castling_rights_debug (ChessCastlingRights rights)
 Prints a debug representation of the given castling rights.
 
bool chess_castling_rights_is_valid (ChessCastlingRights rights)
 Checks if the given castling rights are valid.
 

Detailed Description

Defines the chess castling rights type and related utility functions for representing and manipulating chess castling rights.

Author
Tarek Saeed
Date
2025-06-14

Enumeration Type Documentation

◆ ChessCastlingRights

enum ChessCastlingRights : uint8_t

Represents the castling rights in a chess game.

Enumerator
CHESS_CASTLING_RIGHTS_NONE 

No castling rights.

CHESS_CASTLING_RIGHTS_WHITE_KINGSIDE 

White can castle kingside.

CHESS_CASTLING_RIGHTS_WHITE_QUEENSIDE 

White can castle queenside.

CHESS_CASTLING_RIGHTS_BLACK_KINGSIDE 

Black can castle kingside.

CHESS_CASTLING_RIGHTS_BLACK_QUEENSIDE 

Black can castle queenside.

CHESS_CASTLING_RIGHTS_WHITE 

White can castle on either side.

CHESS_CASTLING_RIGHTS_BLACK 

Black can castle on either side.

CHESS_CASTLING_RIGHTS_ALL 

White and black can both castle on either side.

Function Documentation

◆ chess_castling_rights_debug()

void chess_castling_rights_debug ( ChessCastlingRights  rights)

Prints a debug representation of the given castling rights.

Parameters
[in]rightsThe castling rights to print.

◆ chess_castling_rights_is_valid()

bool chess_castling_rights_is_valid ( ChessCastlingRights  rights)

Checks if the given castling rights are valid.

Parameters
rightsThe castling rights to check.
Returns
[in] true if the castling rights are valid, false otherwise.