forked from LiangChenDLJ/OthelloMonter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMNode.h
54 lines (47 loc) · 1.06 KB
/
MNode.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
#pragma once
#include<iostream>
#include<math.h>
#include<time.h>
#include"Othello.h"
class MNode {
public:
MNode(Othello *othello);
Othello *othello;
int blackCount;
int whiteCount;
int vn;
double an;
vector<MNode*> children;
MNode *parent;
MNode* SearchAndPlay();
MNode* Play(int n);
MNode* Play(int x, int y);
void BackPropagation(double val);
void freetree();
//int fullexpanded;
~MNode();
//FOT TEST
void showtree(int level, int tatrgetlevel);
void showtree(int level);
private:
inline double getTimelimit(){
double base = 20;
double childrenfactor;
double processfactor;
int csize = children.size();
if(csize == 1) return 0;
if (csize > 10) csize = 10;
childrenfactor = csize / 2.0;
int count = blackCount + whiteCount;
if (count < 32) processfactor = 0;
else {
processfactor = (32.0 - count) / 32.0 * 15.0;
}
double res = base + childrenfactor + processfactor;
if(res > 55) res = 55;
return res;
}
int TreePolicy();
int DefaultPolicy();
int SearchOnce();
};