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,435 @@
|
|
|
1
|
+
// 策略:每辆车逐条枚举合法命令,用 tank::step 精确前推一回合(对手取三种模型:不动 / 见线就打 /
|
|
2
|
+
// 预判我落点开炮),再做第二层"是否存在安全应对"的检查;局面评估 = 基地血量差 + 坦克得失 + 到目标的距离场。
|
|
3
|
+
// 目标:攻击手走到离敌方基地 2 格内的炮位;敌人逼近我方基地时最近的车转为猎杀。
|
|
4
|
+
#include "tank.hpp"
|
|
5
|
+
#include <queue>
|
|
6
|
+
#include <vector>
|
|
7
|
+
#include <cstring>
|
|
8
|
+
#include <algorithm>
|
|
9
|
+
|
|
10
|
+
using namespace tank;
|
|
11
|
+
|
|
12
|
+
#define FIXED_PASSES 0
|
|
13
|
+
|
|
14
|
+
static const int INF = 100000;
|
|
15
|
+
static int ME, OP;
|
|
16
|
+
static int atkField[2][CELLS]; // atkField[seat]:seat 方去打对方基地的代价场
|
|
17
|
+
static int huntField[3][CELLS]; // 针对敌方第 k 辆车的猎杀场
|
|
18
|
+
static int starField[CELLS];
|
|
19
|
+
static int goalOf[3]; // 0 = 攻击,1..3 = 猎杀敌车 k-1,4 = 吃星
|
|
20
|
+
static const int* goalField[3];
|
|
21
|
+
|
|
22
|
+
// 调参
|
|
23
|
+
static int FAR_ATK = 1000, FAR_K = 5, HUNT_KEEP = 4;
|
|
24
|
+
static double L2 = 0.5;
|
|
25
|
+
static int W_HUNT = 14, W_HUNT_HOT = 40;
|
|
26
|
+
static int W_STEP = 10, V_BASE = 100, V_MYBASE = 110, V_DEATH = 250, V_UNSAFE = 150, V_KILL = 40, V_KILLY = 12;
|
|
27
|
+
static int V_HP = 40, V_LEVEL = 60, B_BRICK = 6, B_FAR = 5, B_FARSTILL = 15, B_BASEFAR = 8;
|
|
28
|
+
static double M_STAY = 0.55, M_THREAT = 0.45, M_ANT = 0.0;
|
|
29
|
+
|
|
30
|
+
static int danger[CELLS]; // 敌车视线内的格子,寻路时加代价
|
|
31
|
+
static bool useDanger = false;
|
|
32
|
+
static int wStep[3] = {10, 10, 10};
|
|
33
|
+
static int DANGER_NEAR = 0, DANGER_FAR = 0;
|
|
34
|
+
static uint8_t lane[CELLS]; // 敌方炮线(打我基地的线、飞行中的敌弹前方)
|
|
35
|
+
static void dijkstra(const State& s, int* f, bool useLane = false) {
|
|
36
|
+
typedef std::pair<int, int> PI;
|
|
37
|
+
std::priority_queue<PI, std::vector<PI>, std::greater<PI>> pq;
|
|
38
|
+
for (int c = 0; c < CELLS; ++c) if (f[c] < INF) pq.push({f[c], c});
|
|
39
|
+
while (!pq.empty()) {
|
|
40
|
+
PI p = pq.top(); pq.pop();
|
|
41
|
+
if (p.first > f[p.second]) continue;
|
|
42
|
+
for (int d = 0; d < 4; ++d) {
|
|
43
|
+
int n = p.second + DIR_DELTA[d];
|
|
44
|
+
uint8_t g = s.grid[n];
|
|
45
|
+
int w;
|
|
46
|
+
if (g == EMPTY) w = 1; else if (g == BRICK) w = 3; else continue;
|
|
47
|
+
if (useLane && lane[n]) w += 8;
|
|
48
|
+
if (useDanger) w += danger[n];
|
|
49
|
+
if (f[n] > p.first + w) { f[n] = p.first + w; pq.push({f[n], n}); }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static bool buildAtk(const State& s, int seat, int* f, int only = -1) {
|
|
55
|
+
for (int c = 0; c < CELLS; ++c) f[c] = INF;
|
|
56
|
+
int B = s.base_pos[1 - seat];
|
|
57
|
+
bool any = false;
|
|
58
|
+
for (int d = 0; d < 4; ++d) {
|
|
59
|
+
if (only >= 0 && d != only) continue;
|
|
60
|
+
int bricks = 0;
|
|
61
|
+
for (int k = 1; k <= 9; ++k) {
|
|
62
|
+
int c = B + k * DIR_DELTA[d];
|
|
63
|
+
uint8_t g = s.grid[c];
|
|
64
|
+
int far = k > 2 ? (k - 2) * 2 : 0;
|
|
65
|
+
if (g == EMPTY) { f[c] = std::min(f[c], 2 * bricks + far); any = true; }
|
|
66
|
+
else if (g == BRICK) { f[c] = std::min(f[c], 2 * bricks + far + 2); ++bricks; any = true; }
|
|
67
|
+
else if (g == WATER) continue;
|
|
68
|
+
else break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
useDanger = only >= 0;
|
|
72
|
+
dijkstra(s, f);
|
|
73
|
+
useDanger = false;
|
|
74
|
+
return any;
|
|
75
|
+
}
|
|
76
|
+
static int sideField[3][CELLS];
|
|
77
|
+
static bool sideOk[3];
|
|
78
|
+
static int sideOf[3] = {-1, -1, -1};
|
|
79
|
+
static int lastBest[3] = {INF, INF, INF}, stuckCnt[3];
|
|
80
|
+
static int sidePen[3][3], sidePenUntil[3][3];
|
|
81
|
+
|
|
82
|
+
static void buildHunt(const State& s, int e, int* f) {
|
|
83
|
+
for (int c = 0; c < CELLS; ++c) f[c] = INF;
|
|
84
|
+
int P = s.tank[e].pos;
|
|
85
|
+
for (int d = 0; d < 4; ++d) {
|
|
86
|
+
for (int k = 1; k <= 7; ++k) {
|
|
87
|
+
int c = P + k * DIR_DELTA[d];
|
|
88
|
+
uint8_t g = s.grid[c];
|
|
89
|
+
if (g == EMPTY) { if (!lane[c]) f[c] = (k == 1 ? 2 : (k == 2 ? 0 : (k - 2))); }
|
|
90
|
+
else if (g == WATER) continue;
|
|
91
|
+
else break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
dijkstra(s, f, true);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static void buildLane(const State& s) {
|
|
98
|
+
memset(lane, 0, sizeof lane);
|
|
99
|
+
memset(danger, 0, sizeof danger);
|
|
100
|
+
for (int t = 0; t < 3; ++t) {
|
|
101
|
+
int e = tank_id(OP, t);
|
|
102
|
+
if (!s.tank[e].alive) continue;
|
|
103
|
+
for (int d = 0; d < 4; ++d)
|
|
104
|
+
for (int k = 1; k <= 5; ++k) {
|
|
105
|
+
int c = s.tank[e].pos + k * DIR_DELTA[d];
|
|
106
|
+
if (s.grid[c] != EMPTY && s.grid[c] != WATER) break;
|
|
107
|
+
danger[c] += k <= 2 ? DANGER_NEAR : DANGER_FAR;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (int t = 0; t < 3; ++t) {
|
|
111
|
+
int e = tank_id(OP, t);
|
|
112
|
+
if (!s.tank[e].alive) continue;
|
|
113
|
+
for (int d = 0; d < 4; ++d) {
|
|
114
|
+
int k = 1; bool hit = false;
|
|
115
|
+
for (; k <= 14; ++k) {
|
|
116
|
+
uint8_t g = s.grid[s.tank[e].pos + k * DIR_DELTA[d]];
|
|
117
|
+
if (g == BASE0 + ME) { hit = true; break; }
|
|
118
|
+
if (g != EMPTY && g != WATER && g != BRICK) break;
|
|
119
|
+
}
|
|
120
|
+
if (hit) for (int j = 1; j < k; ++j) lane[s.tank[e].pos + j * DIR_DELTA[d]] = 1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
for (int b = 0; b < s.n_bullets; ++b) {
|
|
124
|
+
if (seat_of(s.bullet[b].owner) == ME) continue;
|
|
125
|
+
for (int k = 1; k <= 6; ++k) {
|
|
126
|
+
int c = s.bullet[b].pos + k * DIR_DELTA[s.bullet[b].dir];
|
|
127
|
+
if (s.grid[c] != EMPTY && s.grid[c] != WATER) break;
|
|
128
|
+
lane[c] = 1;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 敌车 e(任意一方的车)"见线就打"的命令:打 foe 方的车或基地
|
|
134
|
+
static Cmd threatCmd(const State& s, int e) {
|
|
135
|
+
const Tank& t = s.tank[e];
|
|
136
|
+
if (!t.alive || !can_fire(s, e)) return STAY;
|
|
137
|
+
int side = seat_of(e);
|
|
138
|
+
int best = -1, bestP = 0;
|
|
139
|
+
for (int d = 0; d < 4; ++d) {
|
|
140
|
+
int bricks = 0;
|
|
141
|
+
for (int k = 1; k <= 14; ++k) {
|
|
142
|
+
int c = t.pos + k * DIR_DELTA[d];
|
|
143
|
+
uint8_t g = s.grid[c];
|
|
144
|
+
if (g == WATER) continue;
|
|
145
|
+
if (g == BRICK) { ++bricks; continue; }
|
|
146
|
+
if (g == BASE0 + (1 - side)) { int p = 20 - bricks; if (p > bestP) { bestP = p; best = d; } break; }
|
|
147
|
+
if (g != EMPTY) break;
|
|
148
|
+
int v = tank_at(s, c);
|
|
149
|
+
if (v >= 0) {
|
|
150
|
+
if (seat_of(v) != side && bricks == 0 && k <= 8) { int p = 100 - k; if (p > bestP) { bestP = p; best = d; } }
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return best < 0 ? STAY : cmd_fire(best);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
static Orders threatOrders(const State& s, int side) {
|
|
159
|
+
Orders o;
|
|
160
|
+
for (int t = 0; t < 3; ++t) o.cmd[t] = threatCmd(s, tank_id(side, t));
|
|
161
|
+
return o;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
static int destOf(const State& s, int i, Cmd c) {
|
|
165
|
+
int p = s.tank[i].pos;
|
|
166
|
+
auto go = [&](int d) { int n = p + DIR_DELTA[d]; if (s.grid[n] == EMPTY && tank_at(s, n) < 0) p = n; };
|
|
167
|
+
if (is_move(c)) go(c - 1);
|
|
168
|
+
else if (is_move2(c)) { go((c - 9) / 4); go((c - 9) % 4); }
|
|
169
|
+
return p;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 预判模型:能开炮的敌车朝我车 i 的落点(2 格内同线)开炮
|
|
173
|
+
static Orders anticipateOrders(const State& s, int side, int i, int dest) {
|
|
174
|
+
Orders o = threatOrders(s, side);
|
|
175
|
+
for (int t = 0; t < 3; ++t) {
|
|
176
|
+
int e = tank_id(side, t);
|
|
177
|
+
if (!s.tank[e].alive || !can_fire(s, e)) continue;
|
|
178
|
+
for (int d = 0; d < 4; ++d) {
|
|
179
|
+
for (int k = 1; k <= 2; ++k) {
|
|
180
|
+
int c = s.tank[e].pos + k * DIR_DELTA[d];
|
|
181
|
+
uint8_t g = s.grid[c];
|
|
182
|
+
if (g != EMPTY && g != WATER) break;
|
|
183
|
+
if (c == dest) { o.cmd[t] = cmd_fire(d); break; }
|
|
184
|
+
int v = tank_at(s, c);
|
|
185
|
+
if (v >= 0 && v != i) break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return o;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
static double evalState(const State& s0, const State& s) {
|
|
193
|
+
double v = 0;
|
|
194
|
+
if (s.done) {
|
|
195
|
+
if (s.winner == ME) v += 100000; else if (s.winner == OP) v -= 100000;
|
|
196
|
+
}
|
|
197
|
+
v += V_BASE * (s0.base_hp[OP] - s.base_hp[OP]);
|
|
198
|
+
v -= V_MYBASE * (s0.base_hp[ME] - s.base_hp[ME]);
|
|
199
|
+
for (int t = 0; t < 3; ++t) {
|
|
200
|
+
int i = tank_id(ME, t), e = tank_id(OP, t);
|
|
201
|
+
const Tank& a0 = s0.tank[i]; const Tank& a = s.tank[i];
|
|
202
|
+
if (a0.alive) {
|
|
203
|
+
if (!a.alive) v -= V_DEATH + 60 * a0.level;
|
|
204
|
+
else {
|
|
205
|
+
int dh = a.hp - 2 * (a.level - a0.level) - a0.hp;
|
|
206
|
+
v += V_HP * dh;
|
|
207
|
+
v += V_LEVEL * (a.level - a0.level);
|
|
208
|
+
int f = goalField[t][a.pos];
|
|
209
|
+
if (f >= INF) f = 60;
|
|
210
|
+
v -= wStep[t] * f;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const Tank& b0 = s0.tank[e]; const Tank& b = s.tank[e];
|
|
214
|
+
if (b0.alive) {
|
|
215
|
+
if (!b.alive) {
|
|
216
|
+
int dy = std::abs(cell_y(b0.pos) - cell_y(s.spawn[e]));
|
|
217
|
+
v += V_KILL + V_KILLY * dy + 60 * b0.level;
|
|
218
|
+
} else {
|
|
219
|
+
int dh = b.hp - 2 * (b.level - b0.level) - b0.hp;
|
|
220
|
+
v -= V_HP * dh;
|
|
221
|
+
v -= V_LEVEL * (b.level - b0.level);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return v;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// 命令本身的启发加分(前推一回合看不到的远期收益)
|
|
229
|
+
static double cmdBonus(const State& s, int i, Cmd c, const int* field) {
|
|
230
|
+
if (!is_fire(c)) return 0;
|
|
231
|
+
int d = c - 5;
|
|
232
|
+
const Tank& t = s.tank[i];
|
|
233
|
+
for (int k = 1; k <= 14; ++k) {
|
|
234
|
+
int cc = t.pos + k * DIR_DELTA[d];
|
|
235
|
+
uint8_t g = s.grid[cc];
|
|
236
|
+
if (g == WATER) continue;
|
|
237
|
+
if (g == BRICK) {
|
|
238
|
+
if (field[cc] <= field[t.pos] && field[cc] < INF) return B_BRICK;
|
|
239
|
+
// 炮线后面是敌方基地
|
|
240
|
+
for (int kk = k + 1; kk <= 14; ++kk) {
|
|
241
|
+
uint8_t g2 = s.grid[t.pos + kk * DIR_DELTA[d]];
|
|
242
|
+
if (g2 == BASE0 + OP) return B_BRICK;
|
|
243
|
+
if (g2 != EMPTY && g2 != WATER && g2 != BRICK) break;
|
|
244
|
+
}
|
|
245
|
+
return -3;
|
|
246
|
+
}
|
|
247
|
+
if (g == BASE0 + OP) return k > 2 ? B_BASEFAR : 0;
|
|
248
|
+
if (g == BASE0 + ME) return -400;
|
|
249
|
+
if (g != EMPTY) return -3;
|
|
250
|
+
int v = tank_at(s, cc);
|
|
251
|
+
if (v >= 0) {
|
|
252
|
+
if (seat_of(v) == ME) return -300;
|
|
253
|
+
if (k <= 2) return 0;
|
|
254
|
+
if (field[t.pos] <= FAR_ATK && k > FAR_K) return -3;
|
|
255
|
+
bool still = s.tank[v].last_fire >= s.turn - 1;
|
|
256
|
+
return (still ? B_FARSTILL : B_FAR) - k;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return -3;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
static bool safeNext(const State& s1, int i) {
|
|
263
|
+
const Tank& t = s1.tank[i];
|
|
264
|
+
if (!t.alive) return true;
|
|
265
|
+
Orders eo = threatOrders(s1, OP);
|
|
266
|
+
Cmd list[N_CMDS];
|
|
267
|
+
int n = legal_commands(s1, i, list);
|
|
268
|
+
for (int k = 0; k < n; ++k) {
|
|
269
|
+
State s2 = s1;
|
|
270
|
+
Orders mo; mo.cmd[type_of(i)] = list[k];
|
|
271
|
+
step_as(s2, ME, mo, eo);
|
|
272
|
+
if (s2.tank[i].alive && s2.tank[i].hp >= t.hp) return true;
|
|
273
|
+
if (s2.done && s2.winner == ME) return true;
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
void init(const State& s, int me) { ME = me; OP = 1 - me; }
|
|
279
|
+
|
|
280
|
+
Orders decide(const State& s, int me) {
|
|
281
|
+
ME = me; OP = 1 - me;
|
|
282
|
+
Orders orders;
|
|
283
|
+
buildAtk(s, ME, atkField[ME]);
|
|
284
|
+
buildAtk(s, OP, atkField[OP]);
|
|
285
|
+
buildLane(s);
|
|
286
|
+
|
|
287
|
+
// 吃星场
|
|
288
|
+
bool anyStar = false;
|
|
289
|
+
for (int c = 0; c < CELLS; ++c) starField[c] = INF;
|
|
290
|
+
for (int k = 0; k < s.n_supply; ++k) if (s.star_mask >> k & 1) { starField[s.supply[k]] = 0; anyStar = true; }
|
|
291
|
+
if (anyStar) dijkstra(s, starField);
|
|
292
|
+
|
|
293
|
+
// 三个方向的炮位分配:尽量一车一个方向,避免挤在同一条路上互相挡
|
|
294
|
+
{
|
|
295
|
+
const int sd[3] = {ME == 0 ? DOWN : UP, LEFT, RIGHT};
|
|
296
|
+
for (int k = 0; k < 3; ++k) sideOk[k] = buildAtk(s, ME, sideField[k], sd[k]);
|
|
297
|
+
for (int t = 0; t < 3; ++t) {
|
|
298
|
+
int i = tank_id(ME, t);
|
|
299
|
+
if (!s.tank[i].alive) { stuckCnt[t] = 0; lastBest[t] = INF; continue; }
|
|
300
|
+
if (sideOf[t] >= 0) {
|
|
301
|
+
int f = sideField[sideOf[t]][s.tank[i].pos];
|
|
302
|
+
if (f < lastBest[t]) { lastBest[t] = f; stuckCnt[t] = 0; }
|
|
303
|
+
else if (f > 0 && ++stuckCnt[t] >= 8) {
|
|
304
|
+
sidePen[t][sideOf[t]] = 25; sidePenUntil[t][sideOf[t]] = s.turn + 30;
|
|
305
|
+
stuckCnt[t] = 0; lastBest[t] = INF;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
int bestTot = INF, bestA[3] = {0, 0, 0};
|
|
310
|
+
for (int a = 0; a < 27; ++a) {
|
|
311
|
+
int as[3] = {a % 3, a / 3 % 3, a / 9};
|
|
312
|
+
int tot = 0, cnt[3] = {0, 0, 0};
|
|
313
|
+
for (int t = 0; t < 3; ++t) {
|
|
314
|
+
int i = tank_id(ME, t);
|
|
315
|
+
int k = as[t];
|
|
316
|
+
if (!sideOk[k]) { tot += 1000; continue; }
|
|
317
|
+
cnt[k]++;
|
|
318
|
+
int pos = s.tank[i].alive ? s.tank[i].pos : s.spawn[i];
|
|
319
|
+
int f = sideField[k][pos]; if (f >= INF) f = 200;
|
|
320
|
+
if (t == FAST) f = (f + 1) / 2;
|
|
321
|
+
if (s.turn < sidePenUntil[t][k]) f += sidePen[t][k];
|
|
322
|
+
if (k != sideOf[t]) f += 3;
|
|
323
|
+
tot += f;
|
|
324
|
+
}
|
|
325
|
+
for (int k = 0; k < 3; ++k) if (cnt[k] > 1) tot += 12 * (cnt[k] - 1);
|
|
326
|
+
if (tot < bestTot) { bestTot = tot; for (int t = 0; t < 3; ++t) bestA[t] = as[t]; }
|
|
327
|
+
}
|
|
328
|
+
for (int t = 0; t < 3; ++t) {
|
|
329
|
+
if (bestA[t] != sideOf[t]) { sideOf[t] = bestA[t]; stuckCnt[t] = 0; lastBest[t] = INF; }
|
|
330
|
+
goalOf[t] = 0;
|
|
331
|
+
goalField[t] = sideOk[sideOf[t]] ? sideField[sideOf[t]] : atkField[ME];
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// 猎杀分配
|
|
336
|
+
for (int t = 0; t < 3; ++t) wStep[t] = W_STEP;
|
|
337
|
+
bool huntBuilt[3] = {false, false, false};
|
|
338
|
+
int order[3] = {0, 1, 2};
|
|
339
|
+
std::sort(order, order + 3, [&](int a, int b) {
|
|
340
|
+
int ea = tank_id(OP, a), eb = tank_id(OP, b);
|
|
341
|
+
int fa = s.tank[ea].alive ? atkField[OP][s.tank[ea].pos] : INF;
|
|
342
|
+
int fb = s.tank[eb].alive ? atkField[OP][s.tank[eb].pos] : INF;
|
|
343
|
+
return fa < fb;
|
|
344
|
+
});
|
|
345
|
+
bool used[3] = {false, false, false};
|
|
346
|
+
int nHunt = 0;
|
|
347
|
+
for (int oi = 0; oi < 3; ++oi) {
|
|
348
|
+
int k = order[oi], e = tank_id(OP, k);
|
|
349
|
+
if (!s.tank[e].alive) continue;
|
|
350
|
+
int thr = atkField[OP][s.tank[e].pos];
|
|
351
|
+
if (thr > 7) continue;
|
|
352
|
+
buildHunt(s, e, huntField[k]); huntBuilt[k] = true;
|
|
353
|
+
int best = -1, bd = INF;
|
|
354
|
+
for (int t = 0; t < 3; ++t) {
|
|
355
|
+
int i = tank_id(ME, t);
|
|
356
|
+
if (used[t] || !s.tank[i].alive) continue;
|
|
357
|
+
int dd = huntField[k][s.tank[i].pos];
|
|
358
|
+
if (t == FAST) dd = (dd + 1) / 2;
|
|
359
|
+
if (goalField[t][s.tank[i].pos] <= HUNT_KEEP && dd > 2) continue;
|
|
360
|
+
if (dd < bd) { bd = dd; best = t; }
|
|
361
|
+
}
|
|
362
|
+
if (best >= 0 && bd <= 14 && nHunt < (s.base_hp[ME] > s.base_hp[OP] + 6 ? 0 : 1)) { ++nHunt; used[best] = true; goalOf[best] = 1 + k; goalField[best] = huntField[k]; wStep[best] = thr <= 1 ? W_HUNT_HOT : W_HUNT; }
|
|
363
|
+
}
|
|
364
|
+
// 吃星:星近就顺路吃
|
|
365
|
+
if (anyStar) {
|
|
366
|
+
for (int t = 0; t < 3; ++t) {
|
|
367
|
+
int i = tank_id(ME, t);
|
|
368
|
+
if (!s.tank[i].alive || goalOf[t] != 0 || s.tank[i].level >= 2) continue;
|
|
369
|
+
int sd = starField[s.tank[i].pos];
|
|
370
|
+
int lim = s.tank[i].level == 0 ? 5 : 3;
|
|
371
|
+
if (sd <= lim && goalField[t][s.tank[i].pos] > 0) { goalOf[t] = 4; goalField[t] = starField; }
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const int seq[3] = {FIRE, ARMOR, FAST};
|
|
376
|
+
int passes = 0;
|
|
377
|
+
for (int pass = 0; pass < 2; ++pass) {
|
|
378
|
+
if (pass > 0) {
|
|
379
|
+
if (FIXED_PASSES ? pass >= FIXED_PASSES : budget_left() < 25) break;
|
|
380
|
+
}
|
|
381
|
+
++passes;
|
|
382
|
+
bool changed = false;
|
|
383
|
+
for (int si = 0; si < 3; ++si) {
|
|
384
|
+
int t = seq[si], i = tank_id(ME, t);
|
|
385
|
+
if (!s.tank[i].alive) continue;
|
|
386
|
+
Cmd list[N_CMDS];
|
|
387
|
+
int n = legal_commands(s, i, list);
|
|
388
|
+
bool cf = can_fire(s, i);
|
|
389
|
+
Orders eStay, eThr = threatOrders(s, OP);
|
|
390
|
+
double bestV = -1e18; Cmd bestC = STAY;
|
|
391
|
+
for (int k = 0; k < n; ++k) {
|
|
392
|
+
Cmd c = list[k];
|
|
393
|
+
if (is_fire(c) && !cf) continue;
|
|
394
|
+
Orders mo = orders; mo.cmd[t] = c;
|
|
395
|
+
double v = cmdBonus(s, i, c, goalField[t]);
|
|
396
|
+
Orders eAnt = anticipateOrders(s, OP, i, destOf(s, i, c));
|
|
397
|
+
const Orders* models[3] = {&eStay, &eThr, &eAnt};
|
|
398
|
+
const double wts[3] = {M_STAY, M_THREAT, M_ANT};
|
|
399
|
+
for (int m = 0; m < 3; ++m) {
|
|
400
|
+
State s1 = s;
|
|
401
|
+
step_as(s1, ME, mo, *models[m]);
|
|
402
|
+
double ev = evalState(s, s1);
|
|
403
|
+
if (wts[m] <= 0) continue;
|
|
404
|
+
if (!s1.done && s1.tank[i].alive && L2 > 0) {
|
|
405
|
+
Cmd l2[N_CMDS];
|
|
406
|
+
int n2 = legal_commands(s1, i, l2);
|
|
407
|
+
bool cf2 = can_fire(s1, i);
|
|
408
|
+
Orders e2; if (m >= 1) e2 = threatOrders(s1, OP);
|
|
409
|
+
double b2 = -1e18;
|
|
410
|
+
for (int k2 = 0; k2 < n2; ++k2) {
|
|
411
|
+
if (is_fire(l2[k2]) && !cf2) continue;
|
|
412
|
+
State s2 = s1;
|
|
413
|
+
Orders m2; m2.cmd[t] = l2[k2];
|
|
414
|
+
step_as(s2, ME, m2, e2);
|
|
415
|
+
double e = evalState(s, s2) + cmdBonus(s1, i, l2[k2], goalField[t]);
|
|
416
|
+
if (e > b2) b2 = e;
|
|
417
|
+
}
|
|
418
|
+
ev = (1 - L2) * ev + L2 * b2;
|
|
419
|
+
}
|
|
420
|
+
if (!s1.done && s1.tank[i].alive && !safeNext(s1, i)) ev -= V_UNSAFE;
|
|
421
|
+
v += wts[m] * ev;
|
|
422
|
+
}
|
|
423
|
+
if (v > bestV) { bestV = v; bestC = c; }
|
|
424
|
+
}
|
|
425
|
+
if (bestC != orders.cmd[t]) changed = true;
|
|
426
|
+
orders.cmd[t] = bestC;
|
|
427
|
+
}
|
|
428
|
+
if (!changed) break;
|
|
429
|
+
}
|
|
430
|
+
#ifdef DBG
|
|
431
|
+
for (int t = 0; t < 3; ++t) { int i = tank_id(ME, t); fprintf(stderr, "t%d goal%d side%d f%d w%d | ", t, goalOf[t], sideOf[t], s.tank[i].alive ? goalField[t][s.tank[i].pos] : -1, wStep[t]); }
|
|
432
|
+
fputc(10, stderr);
|
|
433
|
+
#endif
|
|
434
|
+
return orders;
|
|
435
|
+
}
|