-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgameservices.cpp
More file actions
82 lines (68 loc) · 1.7 KB
/
gameservices.cpp
File metadata and controls
82 lines (68 loc) · 1.7 KB
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
#include "game.hpp"
void Game::flattenHistory() {
for(int s = 0; s < 2; ++s) {
for(int i = 0; i < BOARD_SIZE; ++i) {
for(int j = 0; j < BOARD_SIZE; ++j) {
for(int k = 0; k < BOARD_SIZE; ++k) {
for(int m = 0; m < BOARD_SIZE; ++m) {
historySort[s][i][j][k][m] /= 10000;
}
}
}
}
}
}
void Game::cleanHistory() {
for(int s = 0; s < 2; ++s) {
for(int i = 0; i < BOARD_SIZE; ++i) {
for(int j = 0; j < BOARD_SIZE; ++j) {
for(int k = 0; k < BOARD_SIZE; ++k) {
for(int m = 0; m < BOARD_SIZE; ++m) {
historySort[s][i][j][k][m] = 0;
}
}
}
}
}
}
void Game::clearCash() {
cleanHistory();
for(unsigned int i = 0; i < boardHash.size(); ++i) {
boardHash[i].clean();
}
hash_filled = 0;
}
std::vector<std::string> Game::getStringArray(std::string str) {
std::vector<std::string> result;
std::string tmp;
for(unsigned int i = 0; i < str.size(); ++i) {
if(str[i] == ' ') {
result.push_back(tmp);
tmp.clear();
} else {
tmp.push_back(str[i]);
}
}
result.push_back(tmp);
return result;
}
void Game::setHashSize(int mb_size) {
uint64_t hash_size = ((uint64_t)mb_size * 1024 * 1024);
int bits = 0;
for(uint64_t i = 1; ; i *= 2) {
if(i * sizeof(Hash) >= hash_size || i == 0) {
break;
}
++bits;
}
hash_width = bits;
hash_cutter = std::pow(2, hash_width) - 1;
game_board.hash_width = bits;
game_board.hash_cutter = hash_cutter;
max_hash_filled = pow(2, hash_width);
boardHash.clear();
boardHash = std::vector<Hash>(pow(2, hash_width));
clearCash();
game_board.third_repeat.clear();
game_board.third_repeat = std::vector<int> (pow(2, hash_width), 0);
}