-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.h
98 lines (80 loc) · 2.01 KB
/
common.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef COMMON_H
#define COMMON_H
#include <algorithm>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <ncurses.h>
#include <random>
#include <stdint.h>
#include <stdio.h>
#include <string>
#include <sys/types.h>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define N 13
#define GOAL 5
#define WP 10
#define BCF 1
#define PLAYOUTS 900000
#define BRANCHING 10
#define MCTS_PLY 10
#define UCB_C 1.0
#define UCB_POW 1.0
#define GAMMA 0.95
#define EARLY_CUT (PLAYOUTS / 3)
#define PRINT_CANDY 0
#define PRINT_TREE 0
#define AI_MATCH 0
#define AI_QUIZ 0
#define QUIZ_NUM 4
#define MATCH_NUM 200
#define PUT_BOARD 1
#define PBWIDTH 27
#define PBSTR "||||||||||||||||||||||||||||||||||||||||"
#define LINE_BUFFER (PLAYOUTS / 7)
#define INF 1.0e7
#define MINIMAX_PLY 4
#define TC_RESET "\033[0m"
#define TC_BLACK "\033[30m"
#define TC_RED "\033[91m"
#define TC_GREEN "\033[92m"
#define TC_YELLOW "\033[93m"
#define TC_BLUE "\033[94m"
#define TC_MAGENTA "\033[95m"
#define TC_CYAN "\033[96m"
#define TC_WHITE "\033[97m"
#define TC_CLEAR "\033[2J"
enum Stone { EMPTY, BLACK, WHITE, CANDY };
enum Player { HUMAN, SOFIAI, MARIAI };
typedef pair<int, int> Coords;
typedef vector<Coords> VecCoords;
typedef pair<float, float> Qdist;
static __uint128_t g_lehmer64_state;
static __uint64_t g_fastrand_state;
static inline void lehmer64_seed() {
mt19937_64 mt64_rand(random_device{}());
g_lehmer64_state = mt64_rand() << 1 | 1;
}
static inline uint64_t lehmer64() {
g_lehmer64_state *= UINT64_C(0xda942042e4dd58b5);
return g_lehmer64_state >> 64;
}
static inline void fastrand_seed() {
mt19937_64 mt64_rand(random_device{}());
g_fastrand_state = mt64_rand();
}
static inline uint64_t fastrand() {
g_fastrand_state = (214013 * g_fastrand_state + 2531011);
return (g_fastrand_state >> 16) & 0x7FFF;
}
static inline uint64_t randint(uint8_t low, uint8_t high) {
return lehmer64() % (high - low + 1) + low;
}
#endif