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

Defines the chess position counter type and related functions for keeping count of position occurences. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  ChessPositionCounterEntry
 Entry in the position counter hash table. More...
 
struct  ChessPositionCounter
 Hash table for counting chess positions. More...
 

Typedefs

typedef struct ChessPosition ChessPosition
 Forward declaration of ChessPosition.
 
typedef struct ChessPositionCounterEntry ChessPositionCounterEntry
 Entry in the position counter hash table.
 
typedef struct ChessPositionCounter ChessPositionCounter
 Hash table for counting chess positions.
 

Functions

bool chess_position_counter_is_valid (const ChessPositionCounter *counter)
 Checks if the given position counter is valid.
 
ChessPositionCounter chess_position_counter_new (void)
 Creates a new, empty position counter.
 
void chess_position_counter_drop (ChessPositionCounter *counter)
 Releases resources held by the given position counter.
 
void chess_position_counter_clear (ChessPositionCounter *counter)
 Clears all entries from the given position counter.
 
unsigned int chess_position_counter_count (const ChessPositionCounter *counter, const ChessPosition *position)
 Gets the count for a given position.
 
bool chess_position_counter_increment (ChessPositionCounter *counter, const ChessPosition *position)
 Increments the count for a given position.
 
bool chess_position_counter_decrement (ChessPositionCounter *counter, const ChessPosition *position)
 Decrements the count for a given position.
 

Detailed Description

Defines the chess position counter type and related functions for keeping count of position occurences.

Author
Tarek Saeed
Date
2025-06-14

Typedef Documentation

◆ ChessPositionCounter

Hash table for counting chess positions.

Used to track the number of times each position has occurred, typically for threefold repetition detection.

◆ ChessPositionCounterEntry

Entry in the position counter hash table.

Stores a position key and its associated count.

Function Documentation

◆ chess_position_counter_clear()

void chess_position_counter_clear ( ChessPositionCounter counter)

Clears all entries from the given position counter.

Parameters
[in,out]counterPointer to the position counter to clear.

◆ chess_position_counter_count()

unsigned int chess_position_counter_count ( const ChessPositionCounter counter,
const ChessPosition position 
)

Gets the count for a given position.

Parameters
[in]counterPointer to the position counter.
[in]positionPointer to the position.
Returns
The number of times the position has occurred.

◆ chess_position_counter_decrement()

bool chess_position_counter_decrement ( ChessPositionCounter counter,
const ChessPosition position 
)

Decrements the count for a given position.

Parameters
[in,out]counterPointer to the position counter.
[in]positionPointer to the position.
Returns
true on success, false on failure.

◆ chess_position_counter_drop()

void chess_position_counter_drop ( ChessPositionCounter counter)

Releases resources held by the given position counter.

Parameters
[in,out]counterPointer to the position counter to drop.

◆ chess_position_counter_increment()

bool chess_position_counter_increment ( ChessPositionCounter counter,
const ChessPosition position 
)

Increments the count for a given position.

Parameters
[in,out]counterPointer to the position counter.
[in]positionPointer to the position.
Returns
true on success, false on failure.

◆ chess_position_counter_is_valid()

bool chess_position_counter_is_valid ( const ChessPositionCounter counter)

Checks if the given position counter is valid.

Parameters
[in]counterPointer to the position counter to check.
Returns
true if the position counter is valid, false otherwise.

◆ chess_position_counter_new()

ChessPositionCounter chess_position_counter_new ( void  )

Creates a new, empty position counter.

Returns
The created position counter.