-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNewAI.hpp
85 lines (62 loc) · 1.31 KB
/
NewAI.hpp
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
/*
* NewAI.hpp
*
* Created on: Nov 18, 2012
* Author: mark
*/
#ifndef NEWAI_HPP_
#define NEWAI_HPP_
#include "AI.hpp"
struct Node {
Save save;
int val;
std::vector<std::unique_ptr<Node> > branches;
Move move;
unsigned char depth;
Node() {}
Node(const Save& s, const Move& m, unsigned char depth) : save(s), move(m) , depth(depth){}
void move_and_restore(const Move&);
void jump_and_restore(const Move&);
void print();
};
class NewAI: public BaseAI {
public:
friend struct Node;
NewAI(const unsigned char difficulty);
virtual ~NewAI();
// void print_scene();
Move get_random_move() const;
Move evaluate_game(Game&);
void difficulty(unsigned difficulty)
{
_difficulty = difficulty;
}
unsigned difficulty() const
{
return _difficulty;
}
private:
void gen_moves_black(Node&);
void gen_moves_white(Node&);
void gen_moves(Node& n) {
if (s_game.mTurn)
gen_moves_black(n);
else
gen_moves_white(n);
}
void gen_jumps_black(Node&);
void gen_jumps_white(Node&);
void gen_jumps(Node& n) {
if (s_game.mTurn)
gen_jumps_black(n);
else
gen_jumps_white(n);
}
void gen_outcomes(Node&);
void initialize(const Save&);
int alphabeta(Node& node, int alpha, int beta, bool player);
Node _root;
unsigned char _difficulty;
static Game s_game;
};
#endif /* NEWAI_HPP_ */