dsh-eval-guard 0.2.3 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -13
- package/assets/commit0/instance.json +30 -0
- package/assets/commit0/workspace.zip +0 -0
- package/assets/featurebench/hidden/test_regression.py +690 -0
- package/assets/featurebench/instance.json +16 -0
- package/assets/featurebench/workspace.zip +0 -0
- package/assets/swe-bench-pro/hidden/test.patch +36 -0
- package/assets/swe-bench-pro/instance.json +10 -0
- package/assets/swe-bench-pro/workspace.zip +0 -0
- package/eval/README.md +18 -0
- package/eval/arena/arena/README.md +21 -0
- package/eval/arena/arena/bt.py +104 -0
- package/eval/arena/arena/clock.py +15 -0
- package/eval/arena/arena/core.py +265 -0
- package/eval/arena/arena/run.cmd +24 -0
- package/eval/arena/arena/run.sh +11 -0
- package/eval/arena/arena/schedule.py +79 -0
- package/eval/arena/arena/tournament.py +183 -0
- package/eval/arena/bomberman/bots/README.md +16 -0
- package/eval/arena/bomberman/bots/deepseek-v4.1-flash.cpp +447 -0
- package/eval/arena/bomberman/bots/doubao-seed-2.1.cpp +542 -0
- package/eval/arena/bomberman/bots/glm-5.3.cpp +406 -0
- package/eval/arena/bomberman/bots/gpt-6-astra.cpp +768 -0
- package/eval/arena/bomberman/bots/gpt-6-sol.cpp +444 -0
- package/eval/arena/bomberman/bots/kimi-k3.cpp +432 -0
- package/eval/arena/bomberman/bots/mimo-v2.6-pro.cpp +529 -0
- package/eval/arena/bomberman/bots/opus-5.5.cpp +548 -0
- package/eval/arena/bomberman/bots/qwen-3.8-max.cpp +836 -0
- package/eval/arena/bomberman/tournament/README.md +11 -0
- package/eval/arena/bomberman/tournament/bt.py +56 -0
- package/eval/arena/bomberman/tournament/evaluate.py +199 -0
- package/eval/arena/bomberman/tournament/run.py +79 -0
- package/eval/arena/bomberman/tournament/schedule-2to10.json.gz +0 -0
- package/eval/arena/bomberman/workspace/MANIFEST.json +13 -0
- package/eval/arena/bomberman/workspace/README.md +29 -0
- package/eval/arena/bomberman/workspace/RULES.md +100 -0
- package/eval/arena/bomberman/workspace/baseline.cpp +240 -0
- package/eval/arena/bomberman/workspace/clock.py +25 -0
- package/eval/arena/bomberman/workspace/engine/arena.py +198 -0
- package/eval/arena/bomberman/workspace/engine/build.py +35 -0
- package/eval/arena/bomberman/workspace/engine/engine.py +256 -0
- package/eval/arena/bomberman/workspace/engine/verify_replay.py +24 -0
- package/eval/arena/bomberman/workspace/run.cmd +28 -0
- package/eval/arena/bomberman/workspace/run.sh +16 -0
- package/eval/arena/bomberman/workspace/viewer/index.html +42 -0
- package/eval/arena/ctf/bots/README.md +18 -0
- package/eval/arena/ctf/bots/deepseek-v4.1-flash.cpp +601 -0
- package/eval/arena/ctf/bots/doubao-seed-2.1-turbo.cpp +320 -0
- package/eval/arena/ctf/bots/fable-5.1.cpp +634 -0
- package/eval/arena/ctf/bots/glm-5.3.cpp +689 -0
- package/eval/arena/ctf/bots/gpt-6-astra.cpp +657 -0
- package/eval/arena/ctf/bots/gpt-6.1-sol.cpp +725 -0
- package/eval/arena/ctf/bots/kimi-k3.cpp +667 -0
- package/eval/arena/ctf/bots/mimo-v2.6-pro.cpp +533 -0
- package/eval/arena/ctf/bots/opus-5.5.cpp +645 -0
- package/eval/arena/ctf/bots/qwen-3.8-max.cpp +726 -0
- package/eval/arena/ctf/bots/sonnet-5.5.cpp +569 -0
- package/eval/arena/ctf/tournament/README.md +15 -0
- package/eval/arena/ctf/tournament/formal-2to8.json +31 -0
- package/eval/arena/ctf/tournament/formal-9to15.json +31 -0
- package/eval/arena/ctf/workspace/README.md +41 -0
- package/eval/arena/ctf/workspace/RULES.md +119 -0
- package/eval/arena/ctf/workspace/arena.py +186 -0
- package/eval/arena/ctf/workspace/baseline.cpp +257 -0
- package/eval/arena/ctf/workspace/clock.py +15 -0
- package/eval/arena/ctf/workspace/core.py +265 -0
- package/eval/arena/ctf/workspace/engine.py +389 -0
- package/eval/arena/ctf/workspace/run.cmd +24 -0
- package/eval/arena/ctf/workspace/run.sh +11 -0
- package/eval/arena/ctf/workspace/viewer.html +71 -0
- package/eval/arena/land/bots/README.md +17 -0
- package/eval/arena/land/bots/deepseek-4.1f@workbuddy#1/bot.cpp +608 -0
- package/eval/arena/land/bots/glm-5.3@workbuddy#1/bot.cpp +521 -0
- package/eval/arena/land/bots/gpt-6-astra@codex#1/bot.cpp +373 -0
- package/eval/arena/land/bots/gpt-6-sol@codex#1/bot.cpp +341 -0
- package/eval/arena/land/bots/kimi-k3@workbuddy#1/bot.cpp +492 -0
- package/eval/arena/land/bots/mimo-2.6-pro@zcode#1/bot.cpp +652 -0
- package/eval/arena/land/bots/mystery-model@zcode#1/bot.cpp +466 -0
- package/eval/arena/land/bots/opus-5.5@claude-code#1/bot.cpp +630 -0
- package/eval/arena/land/bots/sonnet-5@claude-code#1/bot.cpp +619 -0
- package/eval/arena/land/tournament/make_replay_page.py +17 -0
- package/eval/arena/land/tournament/rate.py +290 -0
- package/eval/arena/land/tournament/round_robin.py +172 -0
- package/eval/arena/land/tournament/sparring.cpp +356 -0
- package/eval/arena/land/workspace/RULES.md +114 -0
- package/eval/arena/land/workspace/TASK.md +46 -0
- package/eval/arena/land/workspace/anchors/.build/greedy_f2e6d2dea5ca +0 -0
- package/eval/arena/land/workspace/anchors/greedy.cpp +194 -0
- package/eval/arena/land/workspace/anchors/random.cpp +80 -0
- package/eval/arena/land/workspace/clock.py +64 -0
- package/eval/arena/land/workspace/engine/build.py +33 -0
- package/eval/arena/land/workspace/engine/game.py +273 -0
- package/eval/arena/land/workspace/engine/referee.py +308 -0
- package/eval/arena/land/workspace/starter/.build/bot_be32b45b4699 +0 -0
- package/eval/arena/land/workspace/starter/bot.cpp +82 -0
- package/eval/arena/land/workspace/viewer/viewer.html +210 -0
- package/eval/arena/tank/bots/README.md +24 -0
- package/eval/arena/tank/bots/half1/deepseek-v4.1-flash.cpp +367 -0
- package/eval/arena/tank/bots/half1/doubao-seed-evolving.cpp +402 -0
- package/eval/arena/tank/bots/half1/gemini-4-argon.cpp +1132 -0
- package/eval/arena/tank/bots/half1/glm-5.3.cpp +551 -0
- package/eval/arena/tank/bots/half1/gpt-6-astra.cpp +233 -0
- package/eval/arena/tank/bots/half1/gpt-6.1-sol-ultrafast.cpp +350 -0
- package/eval/arena/tank/bots/half1/gpt-6.1-sol.cpp +78 -0
- package/eval/arena/tank/bots/half1/grok-4.7.cpp +1099 -0
- package/eval/arena/tank/bots/half1/haiku-5.5.cpp +210 -0
- package/eval/arena/tank/bots/half1/kimi-k3.cpp +353 -0
- package/eval/arena/tank/bots/half1/mimo-v2.6-pro.cpp +336 -0
- package/eval/arena/tank/bots/half1/muse-wonder-full.cpp +560 -0
- package/eval/arena/tank/bots/half1/opus-5.5.cpp +435 -0
- package/eval/arena/tank/bots/half1/qwen-3.8-max.cpp +537 -0
- package/eval/arena/tank/bots/half2/deepseek-v4.1-flash.cpp +425 -0
- package/eval/arena/tank/bots/half2/doubao-seed-evolving.cpp +308 -0
- package/eval/arena/tank/bots/half2/gemini-4-argon.cpp +1390 -0
- package/eval/arena/tank/bots/half2/glm-5.3.cpp +651 -0
- package/eval/arena/tank/bots/half2/gpt-6-astra.cpp +241 -0
- package/eval/arena/tank/bots/half2/gpt-6.1-sol-ultrafast.cpp +356 -0
- package/eval/arena/tank/bots/half2/gpt-6.1-sol.cpp +87 -0
- package/eval/arena/tank/bots/half2/grok-4.7.cpp +1205 -0
- package/eval/arena/tank/bots/half2/haiku-5.5.cpp +210 -0
- package/eval/arena/tank/bots/half2/kimi-k3.cpp +487 -0
- package/eval/arena/tank/bots/half2/mimo-v2.6-pro.cpp +336 -0
- package/eval/arena/tank/bots/half2/muse-wonder-full.cpp +560 -0
- package/eval/arena/tank/bots/half2/opus-5.5.cpp +476 -0
- package/eval/arena/tank/bots/half2/qwen-3.8-max.cpp +392 -0
- package/eval/arena/tank/tournament/README.md +24 -0
- package/eval/arena/tank/tournament/bt.py +218 -0
- package/eval/arena/tank/tournament/final.json +202 -0
- package/eval/arena/tank/tournament/halftime.json +146 -0
- package/eval/arena/tank/tournament/progress.json +911 -0
- package/eval/arena/tank/tournament/schedule.py +100 -0
- package/eval/arena/tank/tournament/sparring.cpp +928 -0
- package/eval/arena/tank/tournament/tournament.py +1426 -0
- package/eval/arena/tank/workspace/README.md +169 -0
- package/eval/arena/tank/workspace/RULES.md +443 -0
- package/eval/arena/tank/workspace/arena.py +862 -0
- package/eval/arena/tank/workspace/baseline.cpp +259 -0
- package/eval/arena/tank/workspace/clock.py +103 -0
- package/eval/arena/tank/workspace/core.py +712 -0
- package/eval/arena/tank/workspace/engine.py +573 -0
- package/eval/arena/tank/workspace/history/.lock +0 -0
- package/eval/arena/tank/workspace/history/20261017-193610-08715287f91f-bot.cpp +109 -0
- package/eval/arena/tank/workspace/history/20261017-193619-f00b2d5635fa-gpt-6-astra.cpp +241 -0
- package/eval/arena/tank/workspace/history/20261017-193643-63319e0a2b1a-gpt-6_1-sol-ultrafast.cpp +356 -0
- package/eval/arena/tank/workspace/history/20261017-193647-41c1341d0a8a-gemini-4-argon.cpp +1390 -0
- package/eval/arena/tank/workspace/history/20261017-193652-e34c0f45539a-gpt-6_1-sol.cpp +87 -0
- package/eval/arena/tank/workspace/history/20261017-193654-c026348ce96e-opus-5_5.cpp +476 -0
- package/eval/arena/tank/workspace/history/20261017-193655-4a21366e94d1-muse-wonder-full.cpp +560 -0
- package/eval/arena/tank/workspace/history/20261017-193657-dbc4e9969c52-mimo-v2_6-pro.cpp +336 -0
- package/eval/arena/tank/workspace/history/20261017-193703-723cd036eb31-grok-4_7.cpp +1205 -0
- package/eval/arena/tank/workspace/history/20261017-193707-1ebbb227be68-deepseek-v4_1-flash.cpp +425 -0
- package/eval/arena/tank/workspace/history/20261017-193709-aeb0e7202ad5-doubao-seed-evolving.cpp +308 -0
- package/eval/arena/tank/workspace/history/20261017-193710-b21ebeb9bc76-kimi-k3.cpp +487 -0
- package/eval/arena/tank/workspace/history/20261017-193712-54cd86531905-haiku-5_5.cpp +210 -0
- package/eval/arena/tank/workspace/history/20261017-193714-efdb8e35c0bf-qwen-3_8-max.cpp +392 -0
- package/eval/arena/tank/workspace/history/20261017-193715-681423c23fdb-glm-5_3.cpp +651 -0
- package/eval/arena/tank/workspace/history/20261017-193717-1a8b3c75181d-sparring.cpp +928 -0
- package/eval/arena/tank/workspace/history/20261017-193720-1e0803a541e8-baseline.cpp +259 -0
- package/eval/arena/tank/workspace/history/log.jsonl +103 -0
- package/eval/arena/tank/workspace/judge/cycles.hpp +53 -0
- package/eval/arena/tank/workspace/judge/fast.cpp +337 -0
- package/eval/arena/tank/workspace/judge/referee.cpp +125 -0
- package/eval/arena/tank/workspace/judge/speed.cpp +99 -0
- package/eval/arena/tank/workspace/run.cmd +31 -0
- package/eval/arena/tank/workspace/run.sh +23 -0
- package/eval/arena/tank/workspace/tank.hpp +1762 -0
- package/eval/arena/tank/workspace/tank_main.cpp +215 -0
- package/eval/arena/tank/workspace/viewer.html +1150 -0
- package/eval/arena/warehouse/workspace/SPEC.md +130 -0
- package/eval/arena/warehouse/workspace/TASK.md +71 -0
- package/eval/arena/warehouse/workspace/baseline/common.h +88 -0
- package/eval/arena/warehouse/workspace/baseline/main.cpp +27 -0
- package/eval/arena/warehouse/workspace/baseline/old_stuff.cpp +87 -0
- package/eval/arena/warehouse/workspace/baseline/sim.cpp +427 -0
- package/eval/arena/warehouse/workspace/baseline/util.cpp +220 -0
- package/eval/arena/warehouse/workspace/clock.py +42 -0
- package/eval/arena/warehouse/workspace/src/common.h +88 -0
- package/eval/arena/warehouse/workspace/src/main.cpp +27 -0
- package/eval/arena/warehouse/workspace/src/old_stuff.cpp +87 -0
- package/eval/arena/warehouse/workspace/src/sim.cpp +427 -0
- package/eval/arena/warehouse/workspace/src/util.cpp +220 -0
- package/eval/arena/warehouse/workspace/tools/bench.py +119 -0
- package/eval/arena/warehouse/workspace/tools/check_input.py +161 -0
- package/eval/arena/warehouse/workspace/tools/gen.py +132 -0
- package/eval/arena/warehouse/workspace/tools/measure.py +107 -0
- package/eval/arena/warehouse/workspace/workloads/public/pub_crowded.in +1420 -0
- package/eval/arena/warehouse/workspace/workloads/public/pub_crowded.out +9162 -0
- package/eval/arena/warehouse/workspace/workloads/public/pub_dynamic.in +1465 -0
- package/eval/arena/warehouse/workspace/workloads/public/pub_dynamic.out +3439 -0
- package/eval/arena/warehouse/workspace/workloads/public/pub_flood.in +2757 -0
- package/eval/arena/warehouse/workspace/workloads/public/pub_flood.out +3126 -0
- package/eval/arena/warehouse/workspace/workloads/public/pub_small.in +731 -0
- package/eval/arena/warehouse/workspace/workloads/public/pub_small.out +2578 -0
- package/eval/arena/warehouse/workspace/workloads/public/pub_wide.in +528 -0
- package/eval/arena/warehouse/workspace/workloads/public/pub_wide.out +2026 -0
- package/eval/bomberman.py +20 -0
- package/eval/commit0.py +21 -0
- package/eval/common.py +61 -0
- package/eval/ctf.py +20 -0
- package/eval/featurebench.py +25 -0
- package/eval/land.py +20 -0
- package/eval/legacy/bomberman-prices.json +4 -0
- package/eval/legacy/bomberman.py +161 -0
- package/eval/legacy/commit0.py +91 -0
- package/eval/legacy/ctf-prices.json +4 -0
- package/eval/legacy/ctf.py +178 -0
- package/eval/legacy/featurebench.py +103 -0
- package/eval/legacy/land-prices.json +4 -0
- package/eval/legacy/land.py +177 -0
- package/eval/legacy/swe_bench_pro.py +116 -0
- package/eval/legacy/tank-prices.json +3 -0
- package/eval/legacy/tank.py +408 -0
- package/eval/legacy/warehouse-prices.json +4 -0
- package/eval/legacy/warehouse.py +365 -0
- package/eval/swe-bench-pro.py +25 -0
- package/eval/tank.py +20 -0
- package/eval/warehouse.py +20 -0
- package/lib/client/index.js +376 -63
- package/lib/client/index.js.map +1 -1
- package/lib/index.js +684 -27
- package/package.json +2 -1
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
// Bomberman Bot - Strong Competitive Version
|
|
2
|
+
//
|
|
3
|
+
// Core strategy:
|
|
4
|
+
// 1. Time-expanded reachability BFS simulating chain reactions and shrinking
|
|
5
|
+
// 2. Survival is primary: we score reachable cells * survival length as dominant term
|
|
6
|
+
// 3. Threat model: assume the nearest enemy will place a bomb this turn
|
|
7
|
+
// 4. Aggression: if placing a bomb drastically reduces enemy reach, do it
|
|
8
|
+
// 5. Persistent goal navigation with anti-looping visit memory
|
|
9
|
+
// 6. Multi-enemy: find the most vulnerable enemy and focus on them
|
|
10
|
+
// 7. Shrink-aware: value map-center cells; avoid cells about to shrink
|
|
11
|
+
#define AGGRESSIVE 1
|
|
12
|
+
#include <algorithm>
|
|
13
|
+
#include <array>
|
|
14
|
+
#include <cmath>
|
|
15
|
+
#include <iostream>
|
|
16
|
+
#include <queue>
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <vector>
|
|
19
|
+
using namespace std;
|
|
20
|
+
|
|
21
|
+
const string DS = "UDLRS";
|
|
22
|
+
const int DX[] = {0, 0, -1, 1, 0};
|
|
23
|
+
const int DY[] = {-1, 1, 0, 0, 0};
|
|
24
|
+
|
|
25
|
+
int N, P, ME, T, LIMIT, FUSE, RANGE, CAP, FIRE, SHRINK, EVERY;
|
|
26
|
+
|
|
27
|
+
struct Player { int x, y, alive; };
|
|
28
|
+
struct Bomb { int owner, x, y, at; };
|
|
29
|
+
struct Flame { int x, y, end; };
|
|
30
|
+
|
|
31
|
+
vector<string> board;
|
|
32
|
+
vector<Player> players;
|
|
33
|
+
vector<Bomb> bombs;
|
|
34
|
+
vector<Flame> flames;
|
|
35
|
+
|
|
36
|
+
int cell(int x, int y) { return y * N + x; }
|
|
37
|
+
|
|
38
|
+
struct Prediction {
|
|
39
|
+
vector<vector<unsigned char>> safe, open, occupied;
|
|
40
|
+
int horizon;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
Prediction predict(vector<Bomb> bs, int horizon) {
|
|
44
|
+
Prediction out;
|
|
45
|
+
out.horizon = horizon;
|
|
46
|
+
out.safe.assign(horizon, vector<unsigned char>(N*N));
|
|
47
|
+
out.open.assign(horizon, vector<unsigned char>(N*N));
|
|
48
|
+
out.occupied.assign(horizon, vector<unsigned char>(N*N));
|
|
49
|
+
|
|
50
|
+
auto grid = board;
|
|
51
|
+
vector<int> expires(N*N, -1);
|
|
52
|
+
for (auto f : flames) expires[cell(f.x, f.y)] = f.end;
|
|
53
|
+
|
|
54
|
+
for (int k = 0; k < horizon; k++) {
|
|
55
|
+
int now = T + k;
|
|
56
|
+
int layer = now < SHRINK ? 0 : 1 + (now - SHRINK) / EVERY;
|
|
57
|
+
for (int y = 0; y < N; y++) for (int x = 0; x < N; x++)
|
|
58
|
+
if (min({x,y,N-1-x,N-1-y}) <= layer) { grid[y][x] = '#'; expires[cell(x,y)] = -1; }
|
|
59
|
+
|
|
60
|
+
bs.erase(remove_if(bs.begin(), bs.end(), [&](const Bomb& b){ return grid[b.y][b.x]=='#'; }), bs.end());
|
|
61
|
+
|
|
62
|
+
vector<int> at(N*N, -1);
|
|
63
|
+
for (int i = 0; i < (int)bs.size(); i++) {
|
|
64
|
+
at[cell(bs[i].x, bs[i].y)] = i;
|
|
65
|
+
out.occupied[k][cell(bs[i].x, bs[i].y)] = 1;
|
|
66
|
+
}
|
|
67
|
+
for (int y = 0; y < N; y++) for (int x = 0; x < N; x++)
|
|
68
|
+
out.open[k][cell(x,y)] = grid[y][x] == '.';
|
|
69
|
+
|
|
70
|
+
queue<int> q;
|
|
71
|
+
vector<bool> gone(bs.size(), false);
|
|
72
|
+
vector<unsigned char> hit(N*N, 0);
|
|
73
|
+
|
|
74
|
+
for (int i = 0; i < (int)bs.size(); i++)
|
|
75
|
+
if (bs[i].at <= now || expires[cell(bs[i].x, bs[i].y)] >= now)
|
|
76
|
+
q.push(i);
|
|
77
|
+
|
|
78
|
+
while (!q.empty()) {
|
|
79
|
+
int i = q.front(); q.pop();
|
|
80
|
+
if (gone[i]) continue;
|
|
81
|
+
gone[i] = true;
|
|
82
|
+
int bx = bs[i].x, by = bs[i].y;
|
|
83
|
+
hit[cell(bx, by)] = 1;
|
|
84
|
+
for (int d = 0; d < 4; d++) for (int r = 1; r <= RANGE; r++) {
|
|
85
|
+
int x = bx + DX[d]*r, y = by + DY[d]*r;
|
|
86
|
+
if (x<0||y<0||x>=N||y>=N||grid[y][x]=='#') break;
|
|
87
|
+
int c = cell(x,y);
|
|
88
|
+
hit[c] = 1;
|
|
89
|
+
if (grid[y][x] == '+') break;
|
|
90
|
+
if (at[c] >= 0) { q.push(at[c]); break; }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
vector<Bomb> left;
|
|
95
|
+
for (int i = 0; i < (int)bs.size(); i++) if (!gone[i]) left.push_back(bs[i]);
|
|
96
|
+
bs = move(left);
|
|
97
|
+
|
|
98
|
+
for (int y = 0; y < N; y++) for (int x = 0; x < N; x++) {
|
|
99
|
+
int c = cell(x,y);
|
|
100
|
+
if (hit[c]) {
|
|
101
|
+
expires[c] = max(expires[c], now + FIRE - 1);
|
|
102
|
+
if (grid[y][x] == '+') grid[y][x] = '.';
|
|
103
|
+
}
|
|
104
|
+
out.safe[k][c] = grid[y][x] == '.' && expires[c] < now;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
struct Reach {
|
|
111
|
+
array<int,5> count{}, life{};
|
|
112
|
+
array<double,5> utility{};
|
|
113
|
+
int unique = 0;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
Reach reach(const Prediction& pr, int who, int forced_first = -1) {
|
|
117
|
+
const Player& p = players[who];
|
|
118
|
+
if (!p.alive) return {};
|
|
119
|
+
int start = cell(p.x, p.y);
|
|
120
|
+
int horizon = pr.horizon;
|
|
121
|
+
|
|
122
|
+
vector<unsigned char> reached(N*N, 0);
|
|
123
|
+
vector<unsigned char> cur(N*N, 0);
|
|
124
|
+
|
|
125
|
+
Reach result;
|
|
126
|
+
result.utility.fill(-1e30);
|
|
127
|
+
result.life.fill(0);
|
|
128
|
+
|
|
129
|
+
for (int k = 0; k < horizon; k++) {
|
|
130
|
+
vector<unsigned char> next(N*N, 0);
|
|
131
|
+
int now = T + k;
|
|
132
|
+
int layer = now < SHRINK ? 0 : 1 + (now - SHRINK) / EVERY;
|
|
133
|
+
|
|
134
|
+
if (k == 0) {
|
|
135
|
+
int sx = p.x, sy = p.y;
|
|
136
|
+
if (forced_first >= 0) {
|
|
137
|
+
int fc = forced_first;
|
|
138
|
+
int fx = fc % N, fy = fc / N;
|
|
139
|
+
if (min({fx,fy,N-1-fx,N-1-fy}) > layer && pr.safe[k][fc]) {
|
|
140
|
+
unsigned char mask = 0;
|
|
141
|
+
for (int d = 0; d < 5; d++) {
|
|
142
|
+
int nx = sx+DX[d], ny = sy+DY[d];
|
|
143
|
+
int dest = start;
|
|
144
|
+
if (nx>=0&&ny>=0&&nx<N&&ny<N) {
|
|
145
|
+
int z = cell(nx,ny);
|
|
146
|
+
if (pr.open[k][z] && (!pr.occupied[k][z] || z == start))
|
|
147
|
+
dest = z;
|
|
148
|
+
}
|
|
149
|
+
if (dest == fc) mask |= (1 << d);
|
|
150
|
+
}
|
|
151
|
+
next[fc] |= mask;
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
for (int d = 0; d < 5; d++) {
|
|
155
|
+
int nx = sx+DX[d], ny = sy+DY[d];
|
|
156
|
+
int dest = start;
|
|
157
|
+
if (nx>=0&&ny>=0&&nx<N&&ny<N) {
|
|
158
|
+
int z = cell(nx,ny);
|
|
159
|
+
if (pr.open[k][z] && (!pr.occupied[k][z] || z == start))
|
|
160
|
+
dest = z;
|
|
161
|
+
}
|
|
162
|
+
int dx2 = dest%N, dy2 = dest/N;
|
|
163
|
+
if (min({dx2,dy2,N-1-dx2,N-1-dy2}) <= layer) continue;
|
|
164
|
+
if (pr.safe[k][dest]) next[dest] |= (1 << d);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
for (int c = 0; c < N*N; c++) {
|
|
169
|
+
if (!cur[c]) continue;
|
|
170
|
+
int x = c%N, y = c/N;
|
|
171
|
+
if (min({x,y,N-1-x,N-1-y}) <= layer) continue;
|
|
172
|
+
unsigned char mask = cur[c];
|
|
173
|
+
for (int d = 0; d < 5; d++) {
|
|
174
|
+
int nx = x+DX[d], ny = y+DY[d];
|
|
175
|
+
int nc = c;
|
|
176
|
+
if (nx>=0&&ny>=0&&nx<N&&ny<N) {
|
|
177
|
+
int z = cell(nx,ny);
|
|
178
|
+
if (pr.open[k][z] && (!pr.occupied[k][z] || z == c))
|
|
179
|
+
nc = z;
|
|
180
|
+
}
|
|
181
|
+
int cx = nc%N, cy = nc/N;
|
|
182
|
+
if (min({cx,cy,N-1-cx,N-1-cy}) <= layer) continue;
|
|
183
|
+
if (pr.safe[k][nc]) next[nc] |= mask;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
cur = move(next);
|
|
189
|
+
for (int c = 0; c < N*N; c++) if (cur[c]) {
|
|
190
|
+
reached[c] |= cur[c];
|
|
191
|
+
for (int d = 0; d < 5; d++) if (cur[c] & (1 << d))
|
|
192
|
+
result.life[d] = k + 1;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
for (int c = 0; c < N*N; c++) if (reached[c]) {
|
|
197
|
+
result.unique++;
|
|
198
|
+
for (int d = 0; d < 5; d++) if (reached[c] & (1 << d)) {
|
|
199
|
+
result.count[d]++;
|
|
200
|
+
int edge = min({c%N, c/N, N-1-c%N, N-1-c/N});
|
|
201
|
+
result.utility[d] = max(result.utility[d], (double)edge);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
int blast_value(int x, int y) {
|
|
208
|
+
int score = 0;
|
|
209
|
+
for (int d = 0; d < 4; d++) for (int r = 1; r <= RANGE; r++) {
|
|
210
|
+
int nx = x+DX[d]*r, ny = y+DY[d]*r;
|
|
211
|
+
if (nx<0||ny<0||nx>=N||ny>=N||board[ny][nx]=='#') break;
|
|
212
|
+
if (board[ny][nx] == '+') { score += 3; break; }
|
|
213
|
+
for (int i = 0; i < P; i++)
|
|
214
|
+
if (i!=ME && players[i].alive && players[i].x==nx && players[i].y==ny)
|
|
215
|
+
score += 20;
|
|
216
|
+
}
|
|
217
|
+
return score;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
vector<int> dist_bfs(int sx, int sy) {
|
|
221
|
+
vector<int> dist(N*N, 1000000);
|
|
222
|
+
queue<int> q;
|
|
223
|
+
int sc = cell(sx, sy);
|
|
224
|
+
dist[sc] = 0; q.push(sc);
|
|
225
|
+
while (!q.empty()) {
|
|
226
|
+
int c = q.front(); q.pop();
|
|
227
|
+
int x = c%N, y = c/N;
|
|
228
|
+
for (int d = 0; d < 4; d++) {
|
|
229
|
+
int nx = x+DX[d], ny = y+DY[d];
|
|
230
|
+
if (nx<0||ny<0||nx>=N||ny>=N) continue;
|
|
231
|
+
if (board[ny][nx] != '.') continue;
|
|
232
|
+
int nc = cell(nx, ny);
|
|
233
|
+
if (dist[nc] > dist[c] + 1) { dist[nc] = dist[c] + 1; q.push(nc); }
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return dist;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Goal navigation
|
|
240
|
+
vector<int> recent;
|
|
241
|
+
int goal = -1, goal_turn = -10000;
|
|
242
|
+
vector<int> goal_dist;
|
|
243
|
+
|
|
244
|
+
double visit_score(int c) {
|
|
245
|
+
double s = 0;
|
|
246
|
+
for (int i = 0; i < (int)recent.size(); i++)
|
|
247
|
+
if (recent[i] == c) s += 1.0 / (1.0 + 0.15 * (recent.size()-1-i));
|
|
248
|
+
return s;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
void update_goal(const vector<int>& my_dist) {
|
|
252
|
+
int me = cell(players[ME].x, players[ME].y);
|
|
253
|
+
recent.push_back(me);
|
|
254
|
+
if (recent.size() > 40) recent.erase(recent.begin());
|
|
255
|
+
|
|
256
|
+
int layer = T < SHRINK ? 0 : 1 + (T - SHRINK) / EVERY;
|
|
257
|
+
bool need_new = (goal < 0) ||
|
|
258
|
+
(board[goal/N][goal%N] != '.') ||
|
|
259
|
+
(my_dist[goal] >= 1000000) ||
|
|
260
|
+
(T - goal_turn >= 15) ||
|
|
261
|
+
(min({goal%N, goal/N, N-1-goal%N, N-1-goal/N}) <= layer + 1) ||
|
|
262
|
+
(me == goal);
|
|
263
|
+
|
|
264
|
+
if (!need_new) return;
|
|
265
|
+
|
|
266
|
+
goal = -1;
|
|
267
|
+
double best = -1e30;
|
|
268
|
+
for (int c = 0; c < N*N; c++) {
|
|
269
|
+
if (my_dist[c] >= 1000000) continue;
|
|
270
|
+
int x = c%N, y = c/N;
|
|
271
|
+
int edge = min({x, y, N-1-x, N-1-y});
|
|
272
|
+
if (edge <= layer + 1) continue;
|
|
273
|
+
|
|
274
|
+
double bv = blast_value(x, y);
|
|
275
|
+
int until = SHRINK + max(0, edge-1)*EVERY - T;
|
|
276
|
+
|
|
277
|
+
double v = bv * 1.2 - my_dist[c] * 0.7 - visit_score(c) * 1.3;
|
|
278
|
+
if (until < my_dist[c] + 8) v -= 40;
|
|
279
|
+
v += min(5.0, edge * 0.4);
|
|
280
|
+
|
|
281
|
+
// exits = safety
|
|
282
|
+
int exits = 0;
|
|
283
|
+
for (int d = 0; d < 4; d++) {
|
|
284
|
+
int nx = x+DX[d], ny = y+DY[d];
|
|
285
|
+
if (nx>=0&&ny>=0&&nx<N&&ny<N&&board[ny][nx]=='.') exits++;
|
|
286
|
+
}
|
|
287
|
+
v += exits * 0.7;
|
|
288
|
+
|
|
289
|
+
if (v > best) { best = v; goal = c; }
|
|
290
|
+
}
|
|
291
|
+
goal_turn = T;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
int predict_dest(const Prediction& pr, int my_dir) {
|
|
295
|
+
vector<int> ids, origin, target;
|
|
296
|
+
for (int i = 0; i < P; i++) {
|
|
297
|
+
if (!players[i].alive) continue;
|
|
298
|
+
int px = players[i].x, py = players[i].y;
|
|
299
|
+
int old = cell(px, py);
|
|
300
|
+
if (!pr.open[0][old]) continue;
|
|
301
|
+
int d = 4;
|
|
302
|
+
if (i == ME) d = my_dir;
|
|
303
|
+
int nx = px+DX[d], ny = py+DY[d];
|
|
304
|
+
int dest = old;
|
|
305
|
+
if (nx>=0&&ny>=0&&nx<N&&ny<N) {
|
|
306
|
+
int z = cell(nx, ny);
|
|
307
|
+
if (pr.open[0][z] && (!pr.occupied[0][z] || old == z)) dest = z;
|
|
308
|
+
}
|
|
309
|
+
ids.push_back(i); origin.push_back(old); target.push_back(dest);
|
|
310
|
+
}
|
|
311
|
+
auto result = target;
|
|
312
|
+
for (int i = 0; i < (int)ids.size(); i++) {
|
|
313
|
+
int cnt = 0;
|
|
314
|
+
for (int j = 0; j < (int)ids.size(); j++)
|
|
315
|
+
if (target[j] == target[i]) cnt++;
|
|
316
|
+
if (cnt > 1) result[i] = origin[i];
|
|
317
|
+
}
|
|
318
|
+
bool changed = true;
|
|
319
|
+
while (changed) {
|
|
320
|
+
changed = false;
|
|
321
|
+
auto last = result;
|
|
322
|
+
for (int i = 0; i < (int)ids.size(); i++) {
|
|
323
|
+
if (result[i] == origin[i]) continue;
|
|
324
|
+
for (int j = 0; j < (int)ids.size(); j++) {
|
|
325
|
+
if (last[j] == origin[j] && result[i] == origin[j]) {
|
|
326
|
+
result[i] = origin[i]; changed = true; break;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
for (int i = 0; i < (int)ids.size(); i++)
|
|
332
|
+
if (ids[i] == ME) return result[i];
|
|
333
|
+
return cell(players[ME].x, players[ME].y);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
pair<int,int> decide() {
|
|
337
|
+
int horizon = min(10, LIMIT - T);
|
|
338
|
+
if (horizon < 2) horizon = 2;
|
|
339
|
+
Player me = players[ME];
|
|
340
|
+
|
|
341
|
+
Prediction normal = predict(bombs, horizon);
|
|
342
|
+
Reach ordinary = reach(normal, ME);
|
|
343
|
+
|
|
344
|
+
vector<int> enemy_base(P, 0);
|
|
345
|
+
for (int i = 0; i < P; i++) {
|
|
346
|
+
if (i == ME || !players[i].alive) continue;
|
|
347
|
+
enemy_base[i] = reach(normal, i).unique;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
auto my_dist = dist_bfs(me.x, me.y);
|
|
351
|
+
update_goal(my_dist);
|
|
352
|
+
auto gdist = (goal >= 0) ? dist_bfs(goal % N, goal / N) : vector<int>(N*N, 1000000);
|
|
353
|
+
|
|
354
|
+
int active = 0;
|
|
355
|
+
bool on_bomb = false, shared = false;
|
|
356
|
+
for (auto& b : bombs) {
|
|
357
|
+
if (b.owner == ME) active++;
|
|
358
|
+
if (b.x == me.x && b.y == me.y) on_bomb = true;
|
|
359
|
+
}
|
|
360
|
+
for (int i = 0; i < P; i++)
|
|
361
|
+
if (i!=ME && players[i].alive && players[i].x==me.x && players[i].y==me.y)
|
|
362
|
+
shared = true;
|
|
363
|
+
|
|
364
|
+
// Count adjacent exits (safety measure)
|
|
365
|
+
int my_exits = 0;
|
|
366
|
+
for (int d = 0; d < 4; d++) {
|
|
367
|
+
int nx = me.x+DX[d], ny = me.y+DY[d];
|
|
368
|
+
if (nx>=0&&ny>=0&&nx<N&&ny<N&&board[ny][nx]=='.') my_exits++;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Threat model: nearest enemy that can place a bomb
|
|
372
|
+
// In multi-player, extend threat range due to crossfire
|
|
373
|
+
int threat = -1, threat_dist = 10000;
|
|
374
|
+
int threat_range = (P >= 5) ? RANGE * 2 + 5 : RANGE * 2 + 2;
|
|
375
|
+
if (my_exits <= 2) threat_range += 2;
|
|
376
|
+
|
|
377
|
+
for (int i = 0; i < P; i++) {
|
|
378
|
+
if (i==ME || !players[i].alive) continue;
|
|
379
|
+
int e_active = 0, e_on = false;
|
|
380
|
+
for (auto& b : bombs) {
|
|
381
|
+
if (b.owner == i) e_active++;
|
|
382
|
+
if (b.x==players[i].x && b.y==players[i].y) e_on = true;
|
|
383
|
+
}
|
|
384
|
+
int d = abs(players[i].x - me.x) + abs(players[i].y - me.y);
|
|
385
|
+
if (e_active < CAP && !e_on && d <= threat_range && d < threat_dist) {
|
|
386
|
+
threat = i; threat_dist = d;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Count nearby enemies (for crowd avoidance)
|
|
391
|
+
int nearby_enemies = 0;
|
|
392
|
+
for (int i = 0; i < P; i++) {
|
|
393
|
+
if (i==ME || !players[i].alive) continue;
|
|
394
|
+
int d = abs(players[i].x - me.x) + abs(players[i].y - me.y);
|
|
395
|
+
if (d <= RANGE + 2) nearby_enemies++;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
pair<int,int> answer = {4, 0};
|
|
399
|
+
double best = -1e30;
|
|
400
|
+
|
|
401
|
+
for (int place = 0; place <= 1; place++) {
|
|
402
|
+
if (place && (active >= CAP || on_bomb || shared)) continue;
|
|
403
|
+
auto bs = bombs;
|
|
404
|
+
if (place) bs.push_back({ME, me.x, me.y, T + FUSE});
|
|
405
|
+
auto scenario = place ? predict(bs, horizon) : normal;
|
|
406
|
+
auto own = place ? reach(scenario, ME) : ordinary;
|
|
407
|
+
|
|
408
|
+
// Threat scenario with our action
|
|
409
|
+
Reach cautious = own;
|
|
410
|
+
if (threat >= 0) {
|
|
411
|
+
auto te = players[threat];
|
|
412
|
+
auto tbs = bs;
|
|
413
|
+
int e_active = 0, e_on = false;
|
|
414
|
+
for (auto& b : tbs) {
|
|
415
|
+
if (b.owner == threat) e_active++;
|
|
416
|
+
if (b.x == te.x && b.y == te.y) e_on = true;
|
|
417
|
+
}
|
|
418
|
+
if (e_active < CAP && !e_on) {
|
|
419
|
+
tbs.push_back({threat, te.x, te.y, T + FUSE});
|
|
420
|
+
cautious = reach(predict(tbs, horizon), ME);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Denial / kill score
|
|
425
|
+
double denial = 0;
|
|
426
|
+
if (place) {
|
|
427
|
+
denial = blast_value(me.x, me.y) * 0.8 - 3.0;
|
|
428
|
+
for (int i = 0; i < P; i++) {
|
|
429
|
+
if (i==ME || !players[i].alive || enemy_base[i] == 0) continue;
|
|
430
|
+
int remaining = reach(scenario, i).unique;
|
|
431
|
+
double reduction = 1.0 - (double)remaining / enemy_base[i];
|
|
432
|
+
denial += max(0.0, reduction) * 6.0;
|
|
433
|
+
if (remaining == 0) denial += 150.0;
|
|
434
|
+
else if (remaining < 3) denial += 50.0;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
for (int d = 0; d < 5; d++) {
|
|
439
|
+
int dest = predict_dest(scenario, d);
|
|
440
|
+
Reach adjusted = reach(scenario, ME, dest);
|
|
441
|
+
|
|
442
|
+
// Survival is paramount
|
|
443
|
+
double survival_weight = (P >= 5) ? 15000.0 : 10000.0;
|
|
444
|
+
double score = adjusted.life[d] * survival_weight;
|
|
445
|
+
|
|
446
|
+
if (adjusted.count[d] > 0) {
|
|
447
|
+
// More reachable area = safer
|
|
448
|
+
score += 3.0 * log(1.0 + adjusted.count[d]);
|
|
449
|
+
score += 0.3 * adjusted.utility[d];
|
|
450
|
+
|
|
451
|
+
// Goal progress
|
|
452
|
+
if (gdist[dest] < 1000000) score -= gdist[dest] * 1.1;
|
|
453
|
+
|
|
454
|
+
// Anti-looping
|
|
455
|
+
score -= visit_score(dest) * 2.0;
|
|
456
|
+
|
|
457
|
+
// Stay penalty
|
|
458
|
+
if (d == 4) score -= 0.5;
|
|
459
|
+
|
|
460
|
+
// Multi-player: avoid crowded areas
|
|
461
|
+
if (P >= 4 && nearby_enemies >= 2) {
|
|
462
|
+
int new_nearby = 0;
|
|
463
|
+
int nx = me.x + DX[d], ny = me.y + DY[d];
|
|
464
|
+
for (int i = 0; i < P; i++) {
|
|
465
|
+
if (i==ME || !players[i].alive) continue;
|
|
466
|
+
if (abs(players[i].x - nx) + abs(players[i].y - ny) <= RANGE + 1)
|
|
467
|
+
new_nearby++;
|
|
468
|
+
}
|
|
469
|
+
if (new_nearby < nearby_enemies) score += 2.0;
|
|
470
|
+
if (new_nearby > nearby_enemies) score -= 3.0;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// Bomb value
|
|
474
|
+
if (place) {
|
|
475
|
+
score += denial;
|
|
476
|
+
// Don't place if reach is too small after
|
|
477
|
+
if (adjusted.count[d] < max(2, ordinary.count[d] / 3))
|
|
478
|
+
score -= 100;
|
|
479
|
+
// Need at least FUSE+1 turns of survival after placing
|
|
480
|
+
if (adjusted.life[d] < FUSE + 1) score -= 200;
|
|
481
|
+
// In crowded areas, be more cautious about placing
|
|
482
|
+
if (nearby_enemies >= 2) score -= 15.0;
|
|
483
|
+
if (nearby_enemies >= 3) score -= 25.0;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// Threat model penalty
|
|
487
|
+
if (cautious.life[d] < horizon) {
|
|
488
|
+
score -= 30000.0 + (horizon - cautious.life[d]) * 5000.0;
|
|
489
|
+
} else if (cautious.count[d] > 0) {
|
|
490
|
+
score += 1.5 * log(1.0 + cautious.count[d]);
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
score -= 100000;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// Tiebreaker
|
|
497
|
+
score -= 0.001 * ((d * 17 + T * 3 + place * 7) % 100);
|
|
498
|
+
|
|
499
|
+
if (score > best) { best = score; answer = {d, place}; }
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if (answer.second) goal = -1;
|
|
504
|
+
return answer;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
bool read() {
|
|
508
|
+
string word;
|
|
509
|
+
if (!(cin >> word >> T)) return false;
|
|
510
|
+
cin >> word;
|
|
511
|
+
for (auto &row: board) cin >> row;
|
|
512
|
+
for (int i = 0, id; i < P; i++) {
|
|
513
|
+
cin >> word >> id;
|
|
514
|
+
cin >> players[id].x >> players[id].y >> players[id].alive;
|
|
515
|
+
}
|
|
516
|
+
int k;
|
|
517
|
+
cin >> word >> k;
|
|
518
|
+
bombs.resize(k);
|
|
519
|
+
for (auto &b: bombs) cin >> word >> b.owner >> b.x >> b.y >> b.at;
|
|
520
|
+
cin >> word >> k;
|
|
521
|
+
flames.resize(k);
|
|
522
|
+
for (auto &f: flames) cin >> word >> f.x >> f.y >> f.end;
|
|
523
|
+
while (cin >> word) {
|
|
524
|
+
if (word == "END") return true;
|
|
525
|
+
string line; getline(cin, line);
|
|
526
|
+
}
|
|
527
|
+
return false;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
int main(int argc, char** argv) {
|
|
531
|
+
ios::sync_with_stdio(false); cin.tie(nullptr);
|
|
532
|
+
string word;
|
|
533
|
+
if (!(cin >> word >> N >> P >> ME >> LIMIT >> FUSE >> RANGE >> CAP >> FIRE >> SHRINK >> EVERY))
|
|
534
|
+
return 0;
|
|
535
|
+
board.resize(N); players.resize(P);
|
|
536
|
+
while (read()) {
|
|
537
|
+
auto [d,b] = decide();
|
|
538
|
+
cout << T << ' ' << DS[d] << ' ' << b << '\n';
|
|
539
|
+
cout.flush();
|
|
540
|
+
}
|
|
541
|
+
return 0;
|
|
542
|
+
}
|