Chess 0.0.1
A library written in c
Loading...
Searching...
No Matches
position.h
Go to the documentation of this file.
1
8#ifndef CHESS_POSITION_H_INCLUDED
9#define CHESS_POSITION_H_INCLUDED
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
16#include <chess/color.h>
17#include <chess/piece.h>
19#include <chess/square.h>
20
21#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L
22 #include <stdbool.h>
23#endif
24#include <stdint.h>
25
40
45void chess_position_debug(const ChessPosition *position);
46
53
59
65
73
80
87size_t chess_position_from_fen(ChessPosition *position, const char *string);
88
96size_t chess_position_to_fen(const ChessPosition *position, char *string, size_t string_size);
97
104
111
118
125
132
139
145uint64_t chess_position_hash(const ChessPosition *position);
146
147#ifdef __cplusplus
148}
149#endif
150
151#endif // CHESS_POSITION_H_INCLUDED
Defines the chess castling rights type and related utility functions for representing and manipulatin...
ChessCastlingRights
Represents the castling rights in a chess game.
Definition castling_rights.h:22
Defines the chess color type and related utility functions for representing and manipulating chess co...
ChessColor
Represents the color of a chess piece, square or player.
Definition color.h:26
@ CHESS_COLOR_BLACK
Definition color.h:28
Defines the chess piece type and related utility functions for representing and manipulating chess pi...
ChessPiece
Definition piece.h:28
void chess_position_drop(ChessPosition *position)
Releases resources held by the given position.
void chess_position_debug(const ChessPosition *position)
Prints a debug representation of the given position.
bool chess_position_is_check(const ChessPosition *position)
Checks if the current side to move is in check.
size_t chess_position_to_fen(const ChessPosition *position, char *string, size_t string_size)
Converts a position to FEN notation (e.g., "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"...
ChessPiece chess_position_piece_at_square(const ChessPosition *position, ChessSquare square)
Gets the piece at the given square in the given position.
ChessColor chess_position_side_to_move(const ChessPosition *position)
Gets the side to move in the given position.
bool chess_position_is_fifty_move_rule(const ChessPosition *position)
Checks if the fifty-move rule applies to the current position.
size_t chess_position_from_fen(ChessPosition *position, const char *string)
Parses a position from FEN notation (e.g., "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"...
bool chess_position_is_stalemate(const ChessPosition *position)
Checks if the current position is a stalemate.
bool chess_position_is_insufficient_material(const ChessPosition *position)
Checks if there is insufficient material to checkmate.
bool chess_position_is_checkmate(const ChessPosition *position)
Checks if the current side to move is in checkmate.
ChessPosition chess_position_new(void)
Creates a new position initialized to the standard starting position.
bool chess_position_is_valid(const ChessPosition *position)
Checks if the given position is valid.
bool chess_position_is_threefold_repetition(const ChessPosition *position)
Checks if the current position has occurred three or more times (threefold repetition).
uint64_t chess_position_hash(const ChessPosition *position)
Computes a hash value for the given position.
Defines the chess position counter type and related functions for keeping count of position occurence...
Defines the chess square type and related utility functions for representing and manipulating chess s...
ChessSquare
Represents the squares on a chess board, from A1 to H8.
Definition square.h:35
Hash table for counting chess positions.
Definition position_counter.h:38
Represents the position in a chess game.
Definition position.h:30
ChessSquare en_passant_square
Definition position.h:34
ChessCastlingRights castling_rights
Definition position.h:33
ChessSquare king_squares[CHESS_COLOR_BLACK+1]
Definition position.h:37
unsigned int full_move_number
Definition position.h:36
ChessPositionCounter position_counter
Definition position.h:38
unsigned int half_move_clock
Definition position.h:35
ChessColor side_to_move
Definition position.h:32
ChessPiece board[128]
Definition position.h:31