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 
25 typedef struct Book {
26  struct {
27  short year;
28  char month, day;
29  char hour, minute, second;
30  } date;
31  struct {
32  int level;
33  int n_empties;
36  int verbosity;
37  } options;
38  struct {
39  int n_nodes;
40  int n_links;
41  int n_todo;
42  } stats;
44  struct PositionStack* stack;
45  int n;
46  int n_nodes;
50 } Book;
51 
56 typedef struct GameStats {
57  unsigned long long n_wins;
58  unsigned long long n_draws;
59  unsigned long long n_losses;
60  unsigned long long n_lines;
61 } GameStats;
62 
63 // moved from book.c for libEdax. by lavox 2018/1/18
67 typedef struct Link {
68  signed char score;
69  unsigned char move;
70 } Link;
71 
76 typedef struct Position {
77  Board board[1];
80  unsigned int n_wins;
81  unsigned int n_draws;
82  unsigned int n_losses;
83  unsigned int n_lines;
84  struct {
85  short value, lower, upper;
86  } score;
87  unsigned char n_link;
88  unsigned char level;
89  unsigned char done;
90  unsigned char todo;
91 } Position;
92 
93 void book_init(Book*);
94 void book_free(Book*);
95 
96 void book_new(Book*, int, int);
97 void book_load(Book*, const char*);
98 void book_save(Book*, const char*);
99 void book_import(Book*, const char*);
100 void book_export(Book*, const char*);
101 void book_merge(Book*, const Book*);
102 void book_sort(Book *book);
103 void book_negamax(Book*);
104 void book_prune(Book*);
105 void book_deepen(Book*);
107 void book_link(Book*);
108 void book_fix(Book*);
109 void book_fill(Book *book, const int);
110 void book_deviate(Book*, Board*, const int, const int);
111 void book_enhance(Book*, Board*, const int, const int);
112 void book_subtree(Book*, const Board*);
113 void book_play(Book*);
114 
115 void book_info(Book*);
116 void book_show(Book*, Board*);
117 void book_stats(Book *book);
118 bool book_get_moves(Book*, const Board*, MoveList*);
119 bool book_get_random_move(Book*, const Board*, Move*, const int);
120 void book_get_game_stats(Book*, const Board*, GameStats*);
121 void book_get_line(Book*, const Board*, const Move*, Line*);
122 
123 void book_add_board(Book*, const Board*);
124 void book_add_game(Book*, const Game*);
125 void book_add_base(Book*, const Base*);
126 void book_check_base(Book*, const Base*);
127 
129 void book_extract_positions(Book*, const int, const int);
130 
131 void book_feed_hash(const Book*, Board*, Search*);
132 
133 #endif /* EDAX_BOOK_H */
134 
int n_empties
Definition: book.h:33
Definition: base.h:48
unsigned int n_losses
Definition: book.h:82
The opening book.
Definition: book.h:25
struct Position::@3 score
Definition: util.h:87
unsigned char done
Definition: book.h:89
void book_prune(Book *)
Prune a book.
Definition: book.c:1943
unsigned int n_wins
Definition: book.h:80
struct Book::@1 options
void book_enhance(Book *, Board *, const int, const int)
Enhance a book.
Definition: book.c:2006
Definition: move.h:20
short upper
Definition: book.h:85
short year
Definition: book.h:27
void book_deviate(Book *, Board *, const int, const int)
Deviate a book.
Definition: book.c:1896
void book_export(Book *, const char *)
Export an opening book.
Definition: book.c:1525
void book_deepen(Book *)
Deepen a book.
Definition: book.c:1682
char second
Definition: book.h:29
void book_save(Book *, const char *)
Save an opening book.
Definition: book.c:1558
void book_merge(Book *, const Book *)
Merge two opening books.
Definition: book.c:1601
int n_links
Definition: book.h:40
void book_link(Book *)
Link a book.
Definition: book.c:1637
void book_add_base(Book *, const Base *)
Add positions from a game database.
Definition: book.c:2286
void book_load(Book *, const char *)
Load the opening book.
Definition: book.c:1407
int midgame_error
Definition: book.h:34
unsigned long long n_losses
Definition: book.h:59
Definition: board.h:26
struct PositionStack * stack
Definition: book.h:44
char month
Definition: book.h:28
struct Position Position
A position stored in the book.
void book_free(Book *)
Free resources used by the opening book.
Definition: book.c:1368
unsigned char level
Definition: book.h:88
void book_add_board(Book *, const Board *)
Add a position.
Definition: book.c:2215
void book_fill(Book *book, const int)
Fill a book.
Definition: book.c:1855
int n_todo
Definition: book.h:41
Game statistics.
Definition: book.h:56
char hour
Definition: book.h:29
void book_fix(Book *)
Fix a book.
Definition: book.c:1659
struct GameStats GameStats
Game statistics.
unsigned int n_lines
Definition: book.h:83
void book_show(Book *, Board *)
Display a position from the book.
Definition: book.c:2086
unsigned char n_link
Definition: book.h:87
void book_import(Book *, const char *)
Import an opening book.
Definition: book.c:1483
bool need_saving
Definition: book.h:47
int level
Definition: book.h:32
unsigned long long n_lines
Definition: book.h:60
char minute
Definition: book.h:29
unsigned int n_draws
Definition: book.h:81
void book_new(Book *, int, int)
Create a new opening book.
Definition: book.c:1386
unsigned long long n_wins
Definition: book.h:57
int n
Definition: book.h:45
Search * search
Definition: book.h:49
Definition: search.h:95
Random random[1]
Definition: book.h:48
void book_sort(Book *book)
Sort a book.
Definition: book.c:1797
Miscellaneous utilities header.
void book_check_base(Book *, const Base *)
Check positions from a game database.
Definition: book.c:2374
int verbosity
Definition: book.h:36
short lower
Definition: book.h:85
Definition: move.h:35
Link * link
Definition: book.h:79
char day
Definition: book.h:28
Definition: game.h:22
short value
Definition: book.h:85
bool book_get_random_move(Book *, const Board *, Move *, const int)
Get a move at random from the opening book.
Definition: book.c:2156
Board board[1]
Definition: book.h:77
void book_correct_solved(Book *)
Correct wrong solved score in the book.
Definition: book.c:1718
void book_play(Book *)
Play.
Definition: book.c:1817
struct Link Link
a move (with its score) linking to another Position.
void book_info(Book *)
display some book&#39;s informations.
Definition: book.c:2042
void book_init(Book *)
Initialize the opening book.
Definition: book.c:1342
unsigned char todo
Definition: book.h:90
void book_get_game_stats(Book *, const Board *, GameStats *)
Get game statistics from a position.
Definition: book.c:2174
A position stored in the book.
Definition: book.h:76
unsigned long long n_draws
Definition: book.h:58
struct Book::@2 stats
void book_stats(Book *book)
print book statistics.
Definition: book.c:2503
void book_subtree(Book *, const Board *)
Prune a book.
Definition: book.c:1975
struct Book Book
The opening book.
bool book_get_moves(Book *, const Board *, MoveList *)
Get a list of moves from the book.
Definition: book.c:2112
void book_extract_skeleton(Book *, Base *)
Extract book draws to a game base.
Definition: book.c:2439
Definition: move.h:29
int n_nodes
Definition: book.h:39
void book_feed_hash(const Book *, Board *, Search *)
feed hash table from the opening book.
Definition: book.c:2554
void book_add_game(Book *, const Game *)
Add positions from a game.
Definition: book.c:2245
int endcut_error
Definition: book.h:35
void book_negamax(Book *)
Negamax a book.
Definition: book.c:1620
void book_get_line(Book *, const Board *, const Move *, Line *)
Get a variation from the book.
Definition: book.c:2131
struct PositionArray * array
Definition: book.h:43
An array with positions.
Definition: book.c:1108
void book_extract_positions(Book *, const int, const int)
print a set of position.
Definition: book.c:2467
Link leaf
Definition: book.h:78
struct Book::@0 date