-
Notifications
You must be signed in to change notification settings - Fork 0
/
TreeNode.h
68 lines (47 loc) · 1.32 KB
/
TreeNode.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
#ifndef TREE_NODE_H
#define TREE_NODE_H
/*
* Virtual base class and inherited node classes for decision tree nodes.
*
*/
#include <vector>
#include "Game.h"
using namespace std;
typedef vector<int> IntVector;
//---------------------------------------------------------------------
class TreeNode
{
public:
TreeNode(const Game& currentGame) : game_m(currentGame),
value_m(0),
next_move_m(-1) {};
virtual ~TreeNode() {};
int getMove() const { return next_move_m; };
int getValue() const { return value_m; };
protected:
Game game_m;
int value_m;
int next_move_m;
virtual void minimax(int min, int max) = 0;
IntVector getMoves();
};
//---------------------------------------------------------------------
class MaxNode : public TreeNode
{
public:
MaxNode(const Game& current_game, int min=-1, int max=1);
virtual ~MaxNode() {};
protected:
virtual void minimax(int min, int max);
};
//---------------------------------------------------------------------
class MinNode : public TreeNode
{
public:
MinNode(const Game& current_game, int min=-1, int max=1);
virtual ~MinNode() {};
protected:
virtual void minimax(int min, int max);
};
//---------------------------------------------------------------------
#endif // TREE_NODE_H