My Project
book.h
Go to the documentation of this file.
1
11#ifndef EDAX_BOOK_H
12#define EDAX_BOOK_H
13
14#include "base.h"
15#include "board.h"
16#include "game.h"
17#include "search.h"
18#include "util.h"
19#include <stdbool.h>
20
25typedef struct Book {
26 struct {
27 short year;
28 char month, day;
31 struct {
32 int level;
38 struct {
41 int n_todo;
44 struct PositionStack* stack;
45 int n;
46 int n_nodes;
50 volatile Stop count_bestpath_stop; // add by lavox. 2021/8/24
52
57typedef struct GameStats {
58 unsigned long long n_wins;
59 unsigned long long n_draws;
60 unsigned long long n_losses;
61 unsigned long long n_lines;
63
64// moved from book.c for libEdax. by lavox 2018/1/18
68typedef struct Link {
69 signed char score;
70 unsigned char move;
72
77typedef struct Position {
80 // changes variable order for the sake of memory reduction. 2022/6/12 by lavox
81 //unsigned char done; /**< done/undone flag */
82 //unsigned char todo; /**< todo flag */
83 unsigned char flag;
84 unsigned short n_player_bestpaths; // add for libedax by lavox. 2021/8/22
85 unsigned short n_opponent_bestpaths; // add for libedax by lavox. 2021/8/22
87 unsigned int n_wins;
88 unsigned int n_draws;
89 unsigned int n_losses;
90 unsigned int n_lines;
91 struct {
92 short value, lower, upper;
94 unsigned char n_link;
95 unsigned char level;
97
98#define FLAG_DONE 1
99#define FLAG_TODO 2
100#define FLAG_BESTPATH_BLACK 4
101
102void book_init(Book*);
103void book_free(Book*);
104void book_preprocess(Book*);// add for libedax by lavox. 2021/1/23
105void book_stats_clean(Book*);// add for libedax by lavox. 2022/6/12
106
107void book_new(Book*, int, int);
108void book_load(Book*, const char*);
109void book_save(Book*, const char*);
110void book_import(Book*, const char*);
111void book_export(Book*, const char*);
112void book_merge(Book*, const Book*);
113void book_sort(Book *book);
114void book_negamax(Book*);
115void book_prune(Book*);
116void book_deepen(Book*);
118void book_link(Book*);
119void book_fix(Book*);
120void book_fill(Book *book, const int);
121void book_deviate(Book*, Board*, const int, const int);
122void book_enhance(Book*, Board*, const int, const int);
123void book_subtree(Book*, const Board*);
124void book_play(Book*);
125
126void book_info(Book*);
127void book_show(Book*, Board*);
128void book_count_bestpath(Book*, Board*, Position*); // add for libedax by lavox. 2021/8/22
129void book_stop_count_bestpath(Book*); // add for libedax by lavox. 2021/8/24
130Position* book_show_for_api(Book*, Board*);// add for libedax by lavox. 2018/5/20
131void book_count_board_bestpath(Book*, Board*, Position*, const int, const int, const int); // add for libedax by lavox. 2022/6/12
132void book_stats(Book *book);
133bool book_get_moves(Book*, const Board*, MoveList*);
134int book_get_moves_with_position(Book*, const Board*, MoveList*, Position*);// add for libedax by lavox. 2020/2/24
135bool book_get_random_move(Book*, const Board*, Move*, const int);
136void book_get_game_stats(Book*, const Board*, GameStats*);
137void book_get_line(Book*, const Board*, const Move*, Line*);
138
139void book_add_board(Book*, const Board*);
140void book_add_game(Book*, const Game*);
141void book_add_base(Book*, const Base*);
142void book_check_base(Book*, const Base*);
143
145void book_extract_positions(Book*, const int, const int);
146
147void book_feed_hash(const Book*, Board*, Search*);
148
149#endif /* EDAX_BOOK_H */
150
void book_load(Book *, const char *)
Load the opening book.
Definition: book.c:1471
void book_negamax(Book *)
Negamax a book.
Definition: book.c:1684
void book_init(Book *)
Initialize the opening book.
Definition: book.c:1396
void book_stop_count_bestpath(Book *)
Definition: book.c:2323
int book_get_moves_with_position(Book *, const Board *, MoveList *, Position *)
Get a list of moves from the book.
Definition: book.c:2380
Position * book_show_for_api(Book *, Board *)
Display a position from the book.
Definition: book.c:2181
void book_check_base(Book *, const Base *)
Check positions from a game database.
Definition: book.c:2644
void book_stats_clean(Book *)
Definition: book.c:1365
void book_save(Book *, const char *)
Save an opening book.
Definition: book.c:1622
void book_new(Book *, int, int)
Create a new opening book.
Definition: book.c:1450
void book_free(Book *)
Free resources used by the opening book.
Definition: book.c:1422
void book_import(Book *, const char *)
Import an opening book.
Definition: book.c:1547
void book_deviate(Book *, Board *, const int, const int)
Deviate a book.
Definition: book.c:1963
void book_deepen(Book *)
Deepen a book.
Definition: book.c:1746
void book_preprocess(Book *)
clean opening book.
Definition: book.c:1436
void book_feed_hash(const Book *, Board *, Search *)
feed hash table from the opening book.
Definition: book.c:2824
void book_add_board(Book *, const Board *)
Add a position.
Definition: book.c:2485
void book_show(Book *, Board *)
Display a position from the book.
Definition: book.c:2155
void book_extract_positions(Book *, const int, const int)
print a set of position.
Definition: book.c:2737
void book_get_game_stats(Book *, const Board *, GameStats *)
Get game statistics from a position.
Definition: book.c:2444
void book_correct_solved(Book *)
Correct wrong solved score in the book.
Definition: book.c:1782
void book_fix(Book *)
Fix a book.
Definition: book.c:1723
void book_count_board_bestpath(Book *, Board *, Position *, const int, const int, const int)
count the number of "broad" best paths in book.
Definition: book.c:2338
void book_play(Book *)
Play.
Definition: book.c:1882
void book_add_game(Book *, const Game *)
Add positions from a game.
Definition: book.c:2515
void book_get_line(Book *, const Board *, const Move *, Line *)
Get a variation from the book.
Definition: book.c:2401
void book_export(Book *, const char *)
Export an opening book.
Definition: book.c:1589
void book_add_base(Book *, const Base *)
Add positions from a game database.
Definition: book.c:2556
void book_info(Book *)
display some book's informations.
Definition: book.c:2111
void book_sort(Book *book)
Sort a book.
Definition: book.c:1862
void book_merge(Book *, const Book *)
Merge two opening books.
Definition: book.c:1665
void book_link(Book *)
Link a book.
Definition: book.c:1701
void book_prune(Book *)
Prune a book.
Definition: book.c:2010
void book_fill(Book *book, const int)
Fill a book.
Definition: book.c:1922
void book_stats(Book *book)
print book statistics.
Definition: book.c:2773
void book_subtree(Book *, const Board *)
Prune a book.
Definition: book.c:2043
void book_enhance(Book *, Board *, const int, const int)
Enhance a book.
Definition: book.c:2075
bool book_get_moves(Book *, const Board *, MoveList *)
Get a list of moves from the book.
Definition: book.c:2360
void book_count_bestpath(Book *, Board *, Position *)
count the number of best paths in book.
Definition: book.c:2309
bool book_get_random_move(Book *, const Board *, Move *, const int)
Get a move at random from the opening book.
Definition: book.c:2426
void book_extract_skeleton(Book *, Base *)
Extract book draws to a game base.
Definition: book.c:2709
Stop
Definition: const.h:70
Definition: base.h:48
Definition: board.h:26
The opening book.
Definition: book.h:25
struct PositionStack * stack
Definition: book.h:44
struct Book::@2 stats
int endcut_error
Definition: book.h:35
short year
Definition: book.h:27
int n
Definition: book.h:45
struct PositionArray * array
Definition: book.h:43
int n_empties
Definition: book.h:33
bool need_saving
Definition: book.h:47
int verbosity
Definition: book.h:36
int n_links
Definition: book.h:40
int level
Definition: book.h:32
Random random[1]
Definition: book.h:48
char minute
Definition: book.h:29
char second
Definition: book.h:29
char day
Definition: book.h:28
int n_todo
Definition: book.h:41
char hour
Definition: book.h:29
int n_nodes
Definition: book.h:39
struct Book::@0 date
char month
Definition: book.h:28
struct Book::@1 options
volatile Stop count_bestpath_stop
Definition: book.h:50
int midgame_error
Definition: book.h:34
Search * search
Definition: book.h:49
Game statistics.
Definition: book.h:57
unsigned long long n_draws
Definition: book.h:59
unsigned long long n_losses
Definition: book.h:60
unsigned long long n_lines
Definition: book.h:61
unsigned long long n_wins
Definition: book.h:58
Definition: game.h:22
Definition: move.h:35
Definition: move.h:29
Definition: move.h:20
An array with positions.
Definition: book.c:1148
A position stored in the book.
Definition: book.h:77
unsigned int n_wins
Definition: book.h:87
Link leaf
Definition: book.h:79
struct Position::@3 score
unsigned int n_draws
Definition: book.h:88
unsigned char n_link
Definition: book.h:94
unsigned short n_opponent_bestpaths
Definition: book.h:85
unsigned char level
Definition: book.h:95
unsigned int n_lines
Definition: book.h:90
unsigned int n_losses
Definition: book.h:89
unsigned short n_player_bestpaths
Definition: book.h:84
Board board[1]
Definition: book.h:78
short value
Definition: book.h:92
short upper
Definition: book.h:92
Link * link
Definition: book.h:86
short lower
Definition: book.h:92
unsigned char flag
Definition: book.h:83
Definition: util.h:87
Definition: search.h:95
Miscellaneous utilities header.