-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_a1.cpp
More file actions
45 lines (40 loc) · 1.35 KB
/
client_a1.cpp
File metadata and controls
45 lines (40 loc) · 1.35 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
#include "kakomimasu.h"
int main() {
// 自分のbearerTokenを書く
KakomimasuClient kc("");
kc.waitMatching();
kc.getGameInfo();
const int pno = kc.getPlayerNumber();
const vector<vector<int>> points = kc.getPoints();
const int w = kc.getWidth();
const int h = kc.getHeight();
const int nagents = kc.getAgentCount();
// ポイントの高い順ソート
vector<tuple<int, int, int>> pntall;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
pntall.emplace_back(points[i][j], j, i);
}
}
sort(pntall.rbegin(), pntall.rend());
// ↓ここからがAIの中身↓
while (kc.getGameInfo()) {
// ランダムにずらしつつ置けるだけおく
// 置いたものはランダムに8方向に動かす
vector<Action> action;
const int offset = rnd(nagents);
for (int i = 0; i < nagents; i++) {
const Agent agent = kc.getAgent()[i];
if (agent.x == -1) {
const auto [point, x, y] = pntall[i + offset];
action.push_back({i, "PUT", x, y});
} else {
const auto [dx, dy] = DIR[rnd(8)];
action.push_back({i, "MOVE", agent.x + dx, agent.y + dy});
}
}
kc.setAction(action);
kc.waitNextTurn();
}
return 0;
}