-
Notifications
You must be signed in to change notification settings - Fork 0
/
AI.h
41 lines (40 loc) · 1005 Bytes
/
AI.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
#pragma once
#include"Point.h"
#include<vector>
#define MAX_TIMES 1400000
#define My_player 2
#define Enemy_player 1
#define Con 0.707
class AI
{
private:
struct Node{
int player;
int winner;
long long wins;
long long total;
double UCB_a,UCB_b;
std::vector<int> top;
std::vector<Node*> Childrens;
Node(){};
};
int nodescnt=0;
int **board;
int **baseboard;
int M,N;
double XL=0.0;
Node *record_nodes;
Point MCST();
bool JudgeWin(int x,int y);
bool Reasonable(int x,int y);
int Simulation(Node* node);
void CalculateParameters(Node* node);
Node* Selection(Node* root,std::vector<Node*>& path);
void Backpropagation(std::vector<Node*>& path,int result);
Node* newNode(int player);
public:
AI(){};
void GetInfo(const int M, const int N, const int* top, int** _board,const int lastX, const int lastY, const int noX, const int noY);
Point GetAction();
~AI();
};