forked from leela-zero/leela-zero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameState.h
76 lines (62 loc) · 2.3 KB
/
GameState.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
69
70
71
72
73
74
75
76
/*
This file is part of Leela Zero.
Copyright (C) 2017-2018 Gian-Carlo Pascutto and contributors
Leela Zero is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Leela Zero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Leela Zero. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GAMESTATE_H_INCLUDED
#define GAMESTATE_H_INCLUDED
#include <memory>
#include <string>
#include <vector>
#include "FastState.h"
#include "FullBoard.h"
#include "KoState.h"
#include "TimeControl.h"
class GameState : public KoState {
public:
explicit GameState() = default;
explicit GameState(const KoState* rhs) {
// Copy in fields from base class.
*(static_cast<KoState*>(this)) = *rhs;
anchor_game_history();
}
void init_game(int size, float komi);
void reset_game();
bool set_fixed_handicap(int stones);
int set_fixed_handicap_2(int stones);
void place_free_handicap(int stones);
void anchor_game_history(void);
void rewind(void); /* undo infinite */
bool undo_move(void);
bool forward_move(void);
const FullBoard& get_past_board(int moves_ago) const;
void play_move(int color, int vertex);
void play_move(int vertex);
bool play_textmove(const std::string& color,
const std::string& vertex);
void start_clock(int color);
void stop_clock(int color);
TimeControl& get_timecontrol();
void set_timecontrol(int maintime, int byotime, int byostones,
int byoperiods);
void set_timecontrol(TimeControl tmc);
void adjust_time(int color, int time, int stones);
void display_state();
bool has_resigned() const;
int who_resigned() const;
private:
bool valid_handicap(int stones);
std::vector<std::shared_ptr<const KoState>> game_history;
TimeControl m_timecontrol;
int m_resigned{FastBoard::EMPTY};
};
#endif