-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathSGFTree.h
51 lines (40 loc) · 1.37 KB
/
SGFTree.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
#ifndef SGFTREE_H_INCLUDED
#define SGFTREE_H_INCLUDED
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include "KoState.h"
#include "GameState.h"
class SGFTree {
public:
static const int EOT = 0; // End-Of-Tree marker
SGFTree() = default;
void init_state();
KoState * get_state();
KoState * get_state_from_mainline(unsigned int movenum = 999);
GameState follow_mainline_state(unsigned int movenum = 999);
std::vector<int> get_mainline();
void load_from_file(std::string filename, int index = 0);
void load_from_string(std::string gamebuff);
int count_mainline_moves(void);
void add_property(std::string property, std::string value);
SGFTree * add_child();
SGFTree * get_child(unsigned int count);
int get_move(int tomove);
FastBoard::square_t get_winner();
static std::string state_to_string(GameState * state, int compcolor);
private:
void populate_states(void);
void apply_move(int color, int move);
void apply_move(int move);
void copy_state(const SGFTree& state);
int string_to_vertex(const std::string& move) const;
using PropertyMap = std::multimap<std::string, std::string>;
bool m_initialized{false};
KoState m_state;
FastBoard::square_t m_winner{FastBoard::INVAL};
std::vector<SGFTree> m_children;
PropertyMap m_properties;
};
#endif