-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathBook.h
68 lines (47 loc) · 1.91 KB
/
Book.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//-----------------------------------------------------------------------------
/** @file libpentobi_base/Book.h
@author Markus Enzenberger
@copyright GNU General Public License version 3 or later */
//-----------------------------------------------------------------------------
#ifndef LIBPENTOBI_BASE_BOOK_H
#define LIBPENTOBI_BASE_BOOK_H
#include <iosfwd>
#include "Board.h"
#include "PentobiTree.h"
#include "libboardgame_base/PointTransform.h"
#include "libboardgame_base/RandomGenerator.h"
namespace libpentobi_base {
using libboardgame_base::RandomGenerator;
//-----------------------------------------------------------------------------
/** Opening book.
Opening books are stored as trees in SGF files. They contain move
annotation properties according to the SGF standard. The book will select
randomly among the child nodes that have the move annotation good move
or very good move (TE[1] or TE[2]). */
class Book
{
public:
explicit Book(Variant variant);
void load(istream& in);
Move genmove(const Board& bd, Color c);
const PentobiTree& get_tree() const;
private:
using PointTransform = libboardgame_base::PointTransform<Point>;
PentobiTree m_tree;
RandomGenerator m_random;
vector<unique_ptr<PointTransform>> m_transforms;
vector<unique_ptr<PointTransform>> m_inv_transforms;
bool genmove(const Board& bd, Color c, Move& mv,
const PointTransform& transform,
const PointTransform& inv_transform);
const SgfNode* select_child(const Board& bd, Color c,
const PentobiTree& tree, const SgfNode& node,
const PointTransform& inv_transform);
};
inline const PentobiTree& Book::get_tree() const
{
return m_tree;
}
//-----------------------------------------------------------------------------
} // namespace libpentobi_base
#endif // LIBPENTOBI_BASE_BOOK_H