-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAI.h
60 lines (44 loc) · 1.13 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef __AI_h
#define __AI_h
#include <assert.h>
#include <stdbool.h>
#define STATE unsigned int
#define BLACK 0
#define WHITE 1
#define BLANK 2
// coordinate of chessboard specifies top-left point as origin,
// the value of x-coordinate increasing from top to bottom and
// y-coordinate increasing from left to right.
typedef struct pos {
int x, y;
STATE state;
} pos;
pos nxt_step;
pos dir_vec[8];
void init_AI();
#define MAXLEN 225
STATE board[15][15];
#define OUT_OF_BORDER(x, y) \
((x < 0 || y < 0 || x >= 15 || y >= 15) ? true : false)
struct pieces_list {
int len;
pos list[MAXLEN];
};
struct pieces_list search_stack;
double negmax(STATE player, pos pre, int depth, double alpha, double beta);
bool player_win(STATE player, pos p);
static inline double estimate_score(STATE player);
static inline void append(struct pieces_list *l, pos p);
static inline void pop(struct pieces_list *l);
#define WIN 1e9
#define NXT_STEP_WIN 1e7
#define OPPONENT_MUST_DEFEND 1e4
#define NORMAL_2 500
#define NORMAL_1 100
#define NORMAL_0 50
#define USELESS 0
#define DEPTH 5
#define RATIO 1
int maxlen;
#define max(a, b) (a > b ? a : b)
#endif