My Project
Classes | Macros | Typedefs | Functions
book.h File Reference
#include "base.h"
#include "board.h"
#include "game.h"
#include "search.h"
#include "util.h"
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  Book
 The opening book. More...
 
struct  GameStats
 Game statistics. More...
 
struct  Link
 a move (with its score) linking to another Position. More...
 
struct  Position
 A position stored in the book. More...
 

Macros

#define FLAG_DONE   1
 
#define FLAG_TODO   2
 
#define FLAG_BESTPATH_BLACK   4
 

Typedefs

typedef struct Book Book
 The opening book. More...
 
typedef struct GameStats GameStats
 Game statistics. More...
 
typedef struct Link Link
 a move (with its score) linking to another Position. More...
 
typedef struct Position Position
 A position stored in the book. More...
 

Functions

void book_init (Book *)
 Initialize the opening book. More...
 
void book_free (Book *)
 Free resources used by the opening book. More...
 
void book_preprocess (Book *)
 clean opening book. More...
 
void book_stats_clean (Book *)
 
void book_new (Book *, int, int)
 Create a new opening book. More...
 
void book_load (Book *, const char *)
 Load the opening book. More...
 
void book_save (Book *, const char *)
 Save an opening book. More...
 
void book_import (Book *, const char *)
 Import an opening book. More...
 
void book_export (Book *, const char *)
 Export an opening book. More...
 
void book_merge (Book *, const Book *)
 Merge two opening books. More...
 
void book_sort (Book *book)
 Sort a book. More...
 
void book_negamax (Book *)
 Negamax a book. More...
 
void book_prune (Book *)
 Prune a book. More...
 
void book_deepen (Book *)
 Deepen a book. More...
 
void book_correct_solved (Book *)
 Correct wrong solved score in the book. More...
 
void book_link (Book *)
 Link a book. More...
 
void book_fix (Book *)
 Fix a book. More...
 
void book_fill (Book *book, const int)
 Fill a book. More...
 
void book_deviate (Book *, Board *, const int, const int)
 Deviate a book. More...
 
void book_enhance (Book *, Board *, const int, const int)
 Enhance a book. More...
 
void book_subtree (Book *, const Board *)
 Prune a book. More...
 
void book_play (Book *)
 Play. More...
 
void book_info (Book *)
 display some book's informations. More...
 
void book_show (Book *, Board *)
 Display a position from the book. More...
 
void book_count_bestpath (Book *, Board *, Position *)
 count the number of best paths in book. More...
 
void book_stop_count_bestpath (Book *)
 
Positionbook_show_for_api (Book *, Board *)
 Display a position from the book. More...
 
void book_count_board_bestpath (Book *, Board *, Position *, const int, const int, const int)
 count the number of "broad" best paths in book. More...
 
void book_stats (Book *book)
 print book statistics. More...
 
bool book_get_moves (Book *, const Board *, MoveList *)
 Get a list of moves from the book. More...
 
int book_get_moves_with_position (Book *, const Board *, MoveList *, Position *)
 Get a list of moves from the book. More...
 
bool book_get_random_move (Book *, const Board *, Move *, const int)
 Get a move at random from the opening book. More...
 
void book_get_game_stats (Book *, const Board *, GameStats *)
 Get game statistics from a position. More...
 
void book_get_line (Book *, const Board *, const Move *, Line *)
 Get a variation from the book. More...
 
void book_add_board (Book *, const Board *)
 Add a position. More...
 
void book_add_game (Book *, const Game *)
 Add positions from a game. More...
 
void book_add_base (Book *, const Base *)
 Add positions from a game database. More...
 
void book_check_base (Book *, const Base *)
 Check positions from a game database. More...
 
void book_extract_skeleton (Book *, Base *)
 Extract book draws to a game base. More...
 
void book_extract_positions (Book *, const int, const int)
 print a set of position. More...
 
void book_feed_hash (const Book *, Board *, Search *)
 feed hash table from the opening book. More...
 

Detailed Description

Header file for opening book management

Date
1998 - 2017
Author
Richard Delorme
Version
4.4

Macro Definition Documentation

◆ FLAG_BESTPATH_BLACK

#define FLAG_BESTPATH_BLACK   4

◆ FLAG_DONE

#define FLAG_DONE   1

◆ FLAG_TODO

#define FLAG_TODO   2

Typedef Documentation

◆ Book

typedef struct Book Book

The opening book.

struct Book

◆ GameStats

typedef struct GameStats GameStats

Game statistics.

struct GameStat

◆ Link

typedef struct Link Link

a move (with its score) linking to another Position.

struct Link

◆ Position

typedef struct Position Position

A position stored in the book.

struct Position

Function Documentation

◆ book_add_base()

void book_add_base ( Book book,
const Base base 
)

Add positions from a game database.

Parameters
bookopening book.
basegames to add.

◆ book_add_board()

void book_add_board ( Book book,
const Board board 
)

Add a position.

Parameters
bookopening book.
boardposition to add.

◆ book_add_game()

void book_add_game ( Book book,
const Game game 
)

Add positions from a game.

Parameters
bookopening book.
gamegame to add.

◆ book_check_base()

void book_check_base ( Book book,
const Base base 
)

Check positions from a game database.

Parameters
bookopening book.
basegames to add.

◆ book_correct_solved()

void book_correct_solved ( Book book)

Correct wrong solved score in the book.

Correct erroneous solved positions. Edax may be unstable and introduce bugs from time to time...

Parameters
bookopening book.

◆ book_count_bestpath()

void book_count_bestpath ( Book book,
Board board,
Position position 
)

count the number of best paths in book.

Parameters
bookOpening book.
boardStarting position.
positionthe number of best paths(out parameter)

◆ book_count_board_bestpath()

void book_count_board_bestpath ( Book book,
Board board,
Position position,
const int  p_lower,
const int  o_lower,
const int  turn 
)

count the number of "broad" best paths in book.

Parameters
bookOpening book.
boardStarting position.
positionthe number of best paths(out parameter)
p_lowerlower limit for player (BESTPATH_BEST:best moves only)
o_lowerlower limit for opponent (BESTPATH_BEST:best moves only)
turnturn of the position

◆ book_deepen()

void book_deepen ( Book book)

Deepen a book.

Research all non link best move.

Parameters
bookopening book.

◆ book_deviate()

void book_deviate ( Book book,
Board board,
const int  relative_error,
const int  absolute_error 
)

Deviate a book.

Parameters
bookopening book.
boardPosition to start from.
relative_errorError relative to the current position's score.
absolute_errorError relative to the root position's score.

◆ book_enhance()

void book_enhance ( Book book,
Board board,
const int  midgame_error,
const int  endcut_error 
)

Enhance a book.

Parameters
bookopening book.
boardPosition to start from.
midgame_errorError in midgame search.
endcut_errorError in endgame search.

◆ book_export()

void book_export ( Book book,
const char *  file 
)

Export an opening book.

Save the book in a portable text format.

Parameters
bookOpening book.
fileFile name.

◆ book_extract_positions()

void book_extract_positions ( Book book,
const int  n_empties,
const int  n_positions 
)

print a set of position.

Parameters
bookOpening book.
n_emptiesGame stage.
n_positionsNumber of positions to extract.

◆ book_extract_skeleton()

void book_extract_skeleton ( Book book,
Base base 
)

Extract book draws to a game base.

This function supposes that f5d6c4 & f5f6e6f4 are draws and the only draws, excluding the transpositions f5d6c3d3c4 & f5f6e6c6 & c4..., d3..., e6...

Parameters
bookOpening book.
basegame database.

◆ book_feed_hash()

void book_feed_hash ( const Book book,
Board board,
Search search 
)

feed hash table from the opening book.

Parameters
bookOpening book.
boardPosition to start from.
searchHashTables container.

◆ book_fill()

void book_fill ( Book book,
const int  depth 
)

Fill a book.

Parameters
bookopening book.
depthDistance to fill between two positions.

◆ book_fix()

void book_fix ( Book book)

Fix a book.

Parameters
bookopening book.

◆ book_free()

void book_free ( Book book)

Free resources used by the opening book.

Parameters
bookOpening book.

◆ book_get_game_stats()

void book_get_game_stats ( Book book,
const Board board,
GameStats stat 
)

Get game statistics from a position.

Parameters
bookOpening book.
boardPosition to find a move from.
statGame statistics output.

◆ book_get_line()

void book_get_line ( Book book,
const Board board,
const Move move,
Line line 
)

Get a variation from the book.

Parameters
bookOpening book.
boardPosition.
moveFirst move;
lineBariation.

◆ book_get_moves()

bool book_get_moves ( Book book,
const Board board,
MoveList movelist 
)

Get a list of moves from the book.

Parameters
bookOpening book.
boardPosition to display.
movelistList of moves.

◆ book_get_moves_with_position()

int book_get_moves_with_position ( Book book,
const Board board,
MoveList movelist,
Position position 
)

Get a list of moves from the book.

Parameters
bookOpening book.
boardPosition to display.
movelistList of moves.
positionposition.
Returns
symetry. If -1, it means "no book".

◆ book_get_random_move()

bool book_get_random_move ( Book book,
const Board board,
Move move,
const int  randomness 
)

Get a move at random from the opening book.

Parameters
bookOpening book.
boardPosition to find a move from.
moveChosen move.
randomnessRandomness.

◆ book_import()

void book_import ( Book book,
const char *  file 
)

Import an opening book.

Read the opening book from a portable text format. After the book is imported, it is needed to relink & negamax it.

Parameters
bookOpening book.
fileFile name.

◆ book_info()

void book_info ( Book book)

display some book's informations.

Parameters
bookopening book.

◆ book_init()

void book_init ( Book book)

Initialize the opening book.

Create an empty opening book.

Parameters
bookOpening book.

◆ book_link()

void book_link ( Book book)

Link a book.

Parameters
bookopening book.

◆ book_load()

void book_load ( Book book,
const char *  file 
)

Load the opening book.

Parameters
bookOpening book.
fileFile name.

◆ book_merge()

void book_merge ( Book dest,
const Book src 
)

Merge two opening books.

It is needed to relink & negamax the destination book after merging.

Parameters
destDestination opening book.
srcSource opening book.

◆ book_negamax()

void book_negamax ( Book book)

Negamax a book.

Parameters
bookopening book.

◆ book_new()

void book_new ( Book book,
int  level,
int  n_empties 
)

Create a new opening book.

Create an opening book with the initial position & a single non link move.

Parameters
bookOpening book.
levelsearch level to evaluate positions.
n_emptiesnumber of empty positions up to which to evaluate positions.

◆ book_play()

void book_play ( Book book)

Play.

Add positions to the opening book by adding links to position with no links.

Parameters
bookopening book.

◆ book_preprocess()

void book_preprocess ( Book book)

clean opening book.

Parameters
bookOpening book.

◆ book_prune()

void book_prune ( Book book)

Prune a book.

Remove positions Edax cannot reach.

Parameters
bookopening book.

◆ book_save()

void book_save ( Book book,
const char *  file 
)

Save an opening book.

Save the book in a fast binary format.

Parameters
bookOpening book.
fileFile name.

◆ book_show()

void book_show ( Book book,
Board board 
)

Display a position from the book.

Parameters
bookopening book.
boardposition to display.

◆ book_show_for_api()

Position * book_show_for_api ( Book book,
Board board 
)

Display a position from the book.

Parameters
bookopening book.
boardposition to display.

◆ book_sort()

void book_sort ( Book book)

Sort a book.

Parameters
bookopening book.

◆ book_stats()

void book_stats ( Book book)

print book statistics.

Parameters
bookOpening book.

◆ book_stats_clean()

void book_stats_clean ( Book book)

◆ book_stop_count_bestpath()

void book_stop_count_bestpath ( Book book)

◆ book_subtree()

void book_subtree ( Book book,
const Board board 
)

Prune a book.

Remove positions Edax cannot reach.

Parameters
bookopening book.