-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cc
67 lines (54 loc) · 1.5 KB
/
main.cc
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
#include <iostream>
#include "board.h"
#include "mcts.h"
using namespace cita;
using std::cin;
using std::cout;
using std::endl;
using std::string;
#ifdef _BOTZONE_ONLINE
#include <nlohmann/json.hpp>
#include <string>
using nlohmann::json;
// 在线环境使用json交互
int main() {
POINT current = POINT_BLACK;
Board board{};
json input = json::parse(cin);
int cnt{static_cast<int>(input["requests"].size() * 2 - 1)};
for (int i = 0; i < cnt; i++) {
string target{i % 2 == 0 ? "requests" : "responses"};
int x{input[target][i / 2]["x"]}, y{input[target][i / 2]["y"]};
if (x == -1) continue;
board.Place(getPos(x, y), current);
current = getOpp(current);
}
Node root(board, 0, nullptr, getOpp(current));
DebugInfo debug{};
Position result{AutoUct(board, &root, cnt, debug)};
json response = {{"response", {{"x", getX(result)}, {"y", getY(result)}}},
{"debug", debug.info()}};
cout << response.dump() << endl;
}
#else
// 本地调试环境使用简单交互
int main() {
POINT current = POINT_BLACK;
Board board{};
int n{};
cin >> n;
int cnt{2 * n - 1};
for (int i = 0; i < cnt; i++) {
int x{}, y{};
cin >> x >> y;
if (x == -1) continue;
board.Place(getPos(x, y), current);
current = getOpp(current);
}
Node root(board, 0, nullptr, getOpp(current));
DebugInfo debug{};
Position result{AutoUct(board, &root, cnt, debug)};
cout << getX(result) << ' ' << getY(result) << endl;
cout << debug.info() << endl;
}
#endif