-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree.h
51 lines (46 loc) · 1.4 KB
/
tree.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
/* Copyright (C) 2007-2011 Vincent Ollivier
*
* Purple Haze 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.
*
* Purple Haze 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TREE_H
#define TREE_H
#include "position.h"
static const unsigned int MAX_TREE = 512;
class Tree
{
private:
Position tree[MAX_TREE];
uint16_t tree_offset;
uint16_t tree_top;
public:
Tree() : tree_offset(0), tree_top(0) {}
void push() {
tree[tree_top + 1] = tree[tree_top];
++tree_top;
};
void pop() {
--tree_top;
};
Position& top() {
return tree[tree_top];
};
uint16_t get_ply() const {
return tree_offset + tree_top;
};
void set_ply(uint16_t ply) {
tree_offset = ply;
};
bool has_repetition_draw();
};
#endif /* !TREE_H */