My Project
base.c File Reference
#include "base.h"
#include "options.h"
#include "search.h"
#include "perft.h"
#include <assert.h>
#include <stdio.h>
#include <time.h>

Go to the source code of this file.

Functions

static void wthor_header_set (WthorHeader *wheader, unsigned int n_games, unsigned int n, unsigned int year)
 Set wthor header.
 
static bool wthor_header_read (WthorHeader *wheader, FILE *f)
 Read wthor header.
 
static bool wthor_header_write (WthorHeader *wheader, FILE *f)
 Read wthor header.
 
static void wthor_players_init (WthorBase *base)
 Init wthor players.
 
static void wthor_players_load (WthorBase *base, const char *file)
 Load wthor players.
 
static void wthor_players_save (WthorBase *base, const char *file)
 Load wthor players.
 
int wthor_player_get (WthorBase *base, const char *name)
 Get a Wthor player's index.
 
static void wthor_tournaments_load (WthorBase *base, const char *file)
 Load wthor tournaments.
 
void wthor_init (WthorBase *base)
 Initialize a Wthor base.
 
bool wthor_load (WthorBase *base, const char *file)
 Load a wthor base.
 
void wthor_free (WthorBase *base)
 Free a wthor base.
 
bool wthor_save (WthorBase *base, const char *file)
 Save a wthor base.
 
bool base_to_wthor (const Base *base, WthorBase *wthor)
 Convert to a wthor base.
 
void wthor_print_game (WthorBase *base, int i, FILE *f)
 print a wthor game.
 
static void wthorgame_get_board (WthorGame *game, const int n_empties, Board *board, int *player)
 Get a position from a Wthor game.
 
int pv_check (const Board *init_board, Line *pv, Search *search)
 Verify that a PV does not contain errors.
 
void wthor_test (const char *file, Search *search)
 Test Search with a wthor base.
 
void wthor_eval (const char *file, Search *search, unsigned long long histogram[129][65])
 Test Eval with a wthor base.
 
void wthor_edaxify (const char *file)
 Change players to "Edax (delorme)" and tourney to "Etudes" in a wthor base.
 
void base_init (Base *base)
 Initialize a game database.
 
void base_free (Base *base)
 Free resources of a game database.
 
void base_append (Base *base, const Game *game)
 Add a game to a game database.
 
void base_unique (Base *base)
 Make games unique in the game database.
 
bool base_load (Base *base, const char *file)
 Load a game database.
 
void base_save (const Base *base, const char *file)
 Save a game database.
 
void base_to_problem (Base *base, const int n_empties, const char *problem)
 Convert a game database to a set of problems.
 
void base_to_FEN (Base *base, const int n_empties, const char *problem)
 Convert a game database to a set of problems.
 
void base_analyze (Base *base, Search *search, const int n_empties, const bool apply_correction)
 Base analysis.
 
void base_complete (Base *base, Search *search)
 Base analysis.
 
void base_compare (const char *file_1, const char *file_2)
 Base Compare.
 

Detailed Description

Header file for game base management.

Date
1998 - 2017
Author
Richard Delorme
Version
4.4

Function Documentation

◆ base_analyze()

void base_analyze ( Base * base,
Search * search,
const int n_empties,
const bool apply_correction )

Base analysis.

Parameters
baseGame base.
searchSearch engine.
n_emptiesNumber of empties.
apply_correctionCorrect bad moves from the games.

◆ base_append()

void base_append ( Base * base,
const Game * game )

Add a game to a game database.

Parameters
baseGame base.
gameGame to add.

◆ base_compare()

void base_compare ( const char * file_1,
const char * file_2 )

Base Compare.

Display the number of positions two base files have in common.

Parameters
file_1Game base file.
file_2Game base file.

◆ base_complete()

void base_complete ( Base * base,
Search * search )

Base analysis.

Parameters
baseGame base.
searchSearch engine.

◆ base_free()

void base_free ( Base * base)

Free resources of a game database.

Parameters
baseGame base.

◆ base_init()

void base_init ( Base * base)

Initialize a game database.

Parameters
baseGame base.

◆ base_load()

bool base_load ( Base * base,
const char * file )

Load a game database.

Parameters
baseGame base.
fileGame filename.

◆ base_save()

void base_save ( const Base * base,
const char * file )

Save a game database.

Parameters
baseGame base.
fileGame filename.

◆ base_to_FEN()

void base_to_FEN ( Base * base,
const int n_empties,
const char * problem )

Convert a game database to a set of problems.

Parameters
baseGame base.
n_emptiesNumber of empties.
problemProblems filename.

◆ base_to_problem()

void base_to_problem ( Base * base,
const int n_empties,
const char * problem )

Convert a game database to a set of problems.

Parameters
baseGame base.
n_emptiesNumber of empties.
problemProblems filename.

◆ base_to_wthor()

bool base_to_wthor ( const Base * base,
WthorBase * wthor )

Convert to a wthor base.

Parameters
baseGeneric game base.
wthorWthor Game base.

◆ base_unique()

void base_unique ( Base * base)

Make games unique in the game database.

Parameters
baseGame base.

◆ pv_check()

int pv_check ( const Board * init_board,
Line * pv,
Search * search )

Verify that a PV does not contain errors.

Parameters
init_boardInitial board.
pvPV to check
searchSearch engine.

◆ wthor_edaxify()

void wthor_edaxify ( const char * file)

Change players to "Edax (delorme)" and tourney to "Etudes" in a wthor base.

Parameters
fileWthor game file.

◆ wthor_eval()

void wthor_eval ( const char * file,
Search * search,
unsigned long long histogram[129][65] )

Test Eval with a wthor base.

Given a wthor file, compare the result of a search to the theoretical scores.

Parameters
fileGame File.
searchSearch.
histogramoutput array.

◆ wthor_free()

void wthor_free ( WthorBase * base)

Free a wthor base.

Parameters
baseWthor game base.

◆ wthor_header_read()

static bool wthor_header_read ( WthorHeader * wheader,
FILE * f )
static

Read wthor header.

Parameters
wheaderWthor's file header.
fInput stream .

◆ wthor_header_set()

static void wthor_header_set ( WthorHeader * wheader,
unsigned int n_games,
unsigned int n,
unsigned int year )
static

Set wthor header.

Parameters
wheaderWthor's file header.
n_gamesGame number;
nTourney/player number;
yearTournament year;

◆ wthor_header_write()

static bool wthor_header_write ( WthorHeader * wheader,
FILE * f )
static

Read wthor header.

Parameters
wheaderWthor's file header.
fInput stream .

◆ wthor_init()

void wthor_init ( WthorBase * base)

Initialize a Wthor base.

Parameters
baseWthor's base.

◆ wthor_load()

bool wthor_load ( WthorBase * base,
const char * file )

Load a wthor base.

Parameters
baseWthor game base.
fileGame file.

◆ wthor_player_get()

int wthor_player_get ( WthorBase * base,
const char * name )

Get a Wthor player's index.

Parameters
baseWthor base.
namePlayer's name.

◆ wthor_players_init()

static void wthor_players_init ( WthorBase * base)
static

Init wthor players.

Parameters
baseWthor base.

◆ wthor_players_load()

static void wthor_players_load ( WthorBase * base,
const char * file )
static

Load wthor players.

Parameters
baseWthor base.
fileFile name.

◆ wthor_players_save()

static void wthor_players_save ( WthorBase * base,
const char * file )
static

Load wthor players.

Parameters
baseWthor base.
fileFile name.

◆ wthor_print_game()

void wthor_print_game ( WthorBase * base,
int i,
FILE * f )

print a wthor game.

Parameters
baseWthor game base.
igame intex
foutput stream.

◆ wthor_save()

bool wthor_save ( WthorBase * base,
const char * file )

Save a wthor base.

Parameters
baseWthor game base.
fileGame file name.

◆ wthor_test()

void wthor_test ( const char * file,
Search * search )

Test Search with a wthor base.

Parameters
fileGame File.
searchSearch.

◆ wthor_tournaments_load()

static void wthor_tournaments_load ( WthorBase * base,
const char * file )
static

Load wthor tournaments.

Parameters
baseWthor base.
fileFile name.

◆ wthorgame_get_board()

static void wthorgame_get_board ( WthorGame * game,
const int n_empties,
Board * board,
int * player )
static

Get a position from a Wthor game.

Parameters
gameWthor game.
n_emptiesnumber of empty square of the position to find.
boardBoard found.
player