-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTree.h
More file actions
98 lines (70 loc) · 1.57 KB
/
Tree.h
File metadata and controls
98 lines (70 loc) · 1.57 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef _Tree_h_
#define _Tree_h_
#include <vector>
#include <list>
#include "types.h"
class Tree
{
public:
Tree(const TBoard& brd);
Tree(Tree* parent, const TBoard& brd, int depth, bool min, int move);
void expand();
// drop all children
void drop_children();
// run minimax algorithm
int minimax(int maxdpth);
void minimax_propag(int maxdpth);
// evaluate this node using heuristic
void eval();
// accessors
inline bool Minimizing() const;
// returns the state of definiteness for the value contained
// 0 = we don't know
// 1 = we have a corresponding bound
// 2 = we have a result
inline int Definite() const;
inline int Value() const;
inline Tree* Parent() const;
inline int Move() const;
private:
// state stored in this node
TBoard state;
// what the move was that led here
int move;
Tree* parent;
// list of children
std::list< Tree > children;
// depth in the tree
int depth;
// whether this is at the minimizer or maximizer level
// this also stores whose turn it is since player
// is always maximizing
bool min;
// whether the value is definite ( can be <> )
int value_definite;
// value stored
int value;
}; // end class
// drop all children
inline void Tree::drop_children()
{
children.clear();
}
// accessors
inline bool Tree::Minimizing() const
{
return min;
}
inline int Tree::Definite() const
{
return value_definite;
}
inline int Tree::Value() const
{
return value;
}
inline int Tree::Move() const
{
return move;
}
#endif