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,444 @@
|
|
|
1
|
+
#include <algorithm>
|
|
2
|
+
#include <array>
|
|
3
|
+
#include <cmath>
|
|
4
|
+
#include <iostream>
|
|
5
|
+
#include <limits>
|
|
6
|
+
#include <queue>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <vector>
|
|
9
|
+
using namespace std;
|
|
10
|
+
|
|
11
|
+
// All decisions use only the state received on standard input. The forward
|
|
12
|
+
// model reproduces the terrain, shrink, chain explosion and lingering fire
|
|
13
|
+
// phases; opponents' future moves remain deliberately uncertain.
|
|
14
|
+
struct Player { int x=0,y=0,alive=0; };
|
|
15
|
+
struct Bomb { int owner=0,x=0,y=0,at=0,born=-1; };
|
|
16
|
+
struct Flame { int x=0,y=0,last=0; };
|
|
17
|
+
constexpr int dx[5]={0,0,-1,1,0},dy[5]={-1,1,0,0,0};
|
|
18
|
+
constexpr char directions[6]="UDLRS";
|
|
19
|
+
int n,p,me,turnNo,limitTurn,fuseTime,radius,capacity,fireTurns,shrinkStart,shrinkEvery;
|
|
20
|
+
int cells,horizon;
|
|
21
|
+
vector<string> board;
|
|
22
|
+
vector<Player> players;
|
|
23
|
+
vector<Bomb> bombs;
|
|
24
|
+
vector<Flame> flames;
|
|
25
|
+
vector<int> visits,oldPositions,goalDist;
|
|
26
|
+
int goal=-1,goalAge=0;
|
|
27
|
+
|
|
28
|
+
inline int at(int x,int y){return y*n+x;}
|
|
29
|
+
inline bool inside(int x,int y){return x>=0&&y>=0&&x<n&&y<n;}
|
|
30
|
+
inline int depth(int c){int x=c%n,y=c/n;return min(min(x,y),min(n-1-x,n-1-y));}
|
|
31
|
+
inline int layerAt(int t){return t<shrinkStart?0:1+(t-shrinkStart)/shrinkEvery;}
|
|
32
|
+
inline int pos(const Player& a){return at(a.x,a.y);}
|
|
33
|
+
|
|
34
|
+
struct Forecast {
|
|
35
|
+
vector<vector<unsigned char>> open,safe,occupied;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Forecast forecast(vector<Bomb> bs){
|
|
39
|
+
Forecast f;
|
|
40
|
+
f.open.assign(horizon,vector<unsigned char>(cells));
|
|
41
|
+
f.safe.assign(horizon,vector<unsigned char>(cells));
|
|
42
|
+
f.occupied.assign(horizon,vector<unsigned char>(cells));
|
|
43
|
+
vector<char> terrain(cells);
|
|
44
|
+
for(int y=0;y<n;y++)for(int x=0;x<n;x++)terrain[at(x,y)]=board[y][x];
|
|
45
|
+
vector<int> fireEnd(cells,-1);
|
|
46
|
+
for(auto a:flames)fireEnd[at(a.x,a.y)]=max(fireEnd[at(a.x,a.y)],a.last);
|
|
47
|
+
for(int k=0;k<horizon;k++){
|
|
48
|
+
int now=turnNo+k,lay=layerAt(now);
|
|
49
|
+
for(int c=0;c<cells;c++)if(depth(c)<=lay){terrain[c]='#';fireEnd[c]=-1;}
|
|
50
|
+
bs.erase(remove_if(bs.begin(),bs.end(),[&](const Bomb& b){return terrain[at(b.x,b.y)]=='#';}),bs.end());
|
|
51
|
+
vector<int> bombAt(cells,-1);
|
|
52
|
+
for(int i=0;i<(int)bs.size();i++)if(bs[i].born<=now){
|
|
53
|
+
int c=at(bs[i].x,bs[i].y);bombAt[c]=i;f.occupied[k][c]=1;
|
|
54
|
+
}
|
|
55
|
+
for(int c=0;c<cells;c++)f.open[k][c]=(terrain[c]=='.');
|
|
56
|
+
vector<unsigned char> hit(cells),exploded(bs.size());
|
|
57
|
+
queue<int> pending;
|
|
58
|
+
for(int i=0;i<(int)bs.size();i++)if(bs[i].born<=now&&
|
|
59
|
+
(bs[i].at<=now||fireEnd[at(bs[i].x,bs[i].y)]>=now))pending.push(i);
|
|
60
|
+
while(!pending.empty()){
|
|
61
|
+
int i=pending.front();pending.pop();
|
|
62
|
+
if(exploded[i])continue;
|
|
63
|
+
exploded[i]=1;
|
|
64
|
+
Bomb b=bs[i];hit[at(b.x,b.y)]=1;
|
|
65
|
+
for(int d=0;d<4;d++)for(int r=1;r<=radius;r++){
|
|
66
|
+
int x=b.x+dx[d]*r,y=b.y+dy[d]*r;
|
|
67
|
+
if(!inside(x,y))break;
|
|
68
|
+
int c=at(x,y);
|
|
69
|
+
if(terrain[c]=='#')break;
|
|
70
|
+
hit[c]=1;
|
|
71
|
+
if(terrain[c]=='+')break;
|
|
72
|
+
if(bombAt[c]>=0){pending.push(bombAt[c]);break;}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
vector<Bomb> kept;
|
|
76
|
+
for(int i=0;i<(int)bs.size();i++)if(!exploded[i])kept.push_back(bs[i]);
|
|
77
|
+
bs.swap(kept);
|
|
78
|
+
for(int c=0;c<cells;c++){
|
|
79
|
+
if(hit[c]){fireEnd[c]=max(fireEnd[c],now+fireTurns-1);if(terrain[c]=='+')terrain[c]='.';}
|
|
80
|
+
f.safe[k][c]=terrain[c]=='.'&&fireEnd[c]<now;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return f;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
struct Reach {
|
|
87
|
+
int life=0,count=0;
|
|
88
|
+
double best=-1e6;
|
|
89
|
+
double mobility=0;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// Forced landing applies only to the first step. Later movement is a union
|
|
93
|
+
// of all legal routes, so an action is rejected if it cannot survive its fuse.
|
|
94
|
+
Reach reach(const Forecast& f,int start,int landing,const vector<double>* endValue=nullptr){
|
|
95
|
+
vector<unsigned char> current(cells),next(cells);
|
|
96
|
+
current[start]=1;
|
|
97
|
+
Reach out;
|
|
98
|
+
for(int k=0;k<horizon;k++){
|
|
99
|
+
fill(next.begin(),next.end(),0);
|
|
100
|
+
int lay=layerAt(turnNo+k);
|
|
101
|
+
for(int c=0;c<cells;c++)if(current[c]&&depth(c)>lay){
|
|
102
|
+
int x=c%n,y=c/n;
|
|
103
|
+
if(k==0){
|
|
104
|
+
if(landing>=0&&f.open[k][landing]&&f.safe[k][landing]&&
|
|
105
|
+
(!f.occupied[k][landing]||landing==c))next[landing]=1;
|
|
106
|
+
} else for(int d=0;d<5;d++){
|
|
107
|
+
int xx=x+dx[d],yy=y+dy[d];
|
|
108
|
+
if(!inside(xx,yy))continue;
|
|
109
|
+
int z=at(xx,yy);
|
|
110
|
+
if(f.open[k][z]&&f.safe[k][z]&&(!f.occupied[k][z]||z==c))next[z]=1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
current.swap(next);
|
|
114
|
+
int count=0;
|
|
115
|
+
for(auto v:current)count+=v;
|
|
116
|
+
if(!count)break;
|
|
117
|
+
out.life=k+1;
|
|
118
|
+
out.count=count;
|
|
119
|
+
if(k<6)out.mobility+=log1p(count)/(1.0+.35*k);
|
|
120
|
+
}
|
|
121
|
+
if(endValue&&out.life==horizon)
|
|
122
|
+
for(int c=0;c<cells;c++)if(current[c])out.best=max(out.best,(*endValue)[c]);
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
vector<int> distances(int origin){
|
|
127
|
+
vector<int> dist(cells,10000);
|
|
128
|
+
if(origin<0||origin>=cells)return dist;
|
|
129
|
+
queue<int> q;dist[origin]=0;q.push(origin);
|
|
130
|
+
while(!q.empty()){
|
|
131
|
+
int c=q.front();q.pop();int x=c%n,y=c/n;
|
|
132
|
+
for(int d=0;d<4;d++){
|
|
133
|
+
int xx=x+dx[d],yy=y+dy[d];if(!inside(xx,yy)||board[yy][xx]!='.')continue;
|
|
134
|
+
int z=at(xx,yy);if(dist[z]>dist[c]+1){dist[z]=dist[c]+1;q.push(z);}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return dist;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
int cratesHit(int c){
|
|
141
|
+
int x=c%n,y=c/n,count=0;
|
|
142
|
+
for(int d=0;d<4;d++)for(int r=1;r<=radius;r++){
|
|
143
|
+
int xx=x+dx[d]*r,yy=y+dy[d]*r;
|
|
144
|
+
if(!inside(xx,yy)||board[yy][xx]=='#')break;
|
|
145
|
+
if(board[yy][xx]=='+'){count++;break;}
|
|
146
|
+
bool bombBlock=false;for(const auto& b:bombs)if(b.x==xx&&b.y==yy)bombBlock=true;
|
|
147
|
+
if(bombBlock)break;
|
|
148
|
+
}
|
|
149
|
+
return count;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
double visitCost(int c){
|
|
153
|
+
double v=0;
|
|
154
|
+
int len=visits.size();
|
|
155
|
+
for(int i=max(0,len-25);i<len;i++)if(visits[i]==c)v+=1.0/(1.0+.12*(len-1-i));
|
|
156
|
+
return v;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
vector<double> positionValue;
|
|
160
|
+
void chooseGoal(){
|
|
161
|
+
int start=pos(players[me]);
|
|
162
|
+
auto from=distances(start);
|
|
163
|
+
int lay=layerAt(turnNo);
|
|
164
|
+
positionValue.assign(cells,-1e5);
|
|
165
|
+
vector<double> site(cells,-1e5);
|
|
166
|
+
for(int c=0;c<cells;c++)if(board[c/n][c%n]=='.'){
|
|
167
|
+
int x=c%n,y=c/n,edge=depth(c);
|
|
168
|
+
int nextWall=shrinkStart+max(0,edge-1)*shrinkEvery;
|
|
169
|
+
double urgency=0;
|
|
170
|
+
if(nextWall-turnNo<30)urgency-=max(0,30-(nextWall-turnNo))*1.5;
|
|
171
|
+
double cr=cratesHit(c);
|
|
172
|
+
double enemy=0;
|
|
173
|
+
for(int i=0;i<p;i++)if(i!=me&&players[i].alive){
|
|
174
|
+
int md=abs(x-players[i].x)+abs(y-players[i].y);
|
|
175
|
+
if(md<=8)enemy=max(enemy,5.5-abs(md-3)*1.2);
|
|
176
|
+
}
|
|
177
|
+
double central=edge*.38;
|
|
178
|
+
if(turnNo>=shrinkStart-70)central+=edge*.85;
|
|
179
|
+
site[c]=cr*4.3+enemy+central+urgency-1.4*visitCost(c);
|
|
180
|
+
positionValue[c]=site[c];
|
|
181
|
+
}
|
|
182
|
+
bool oldValid=goal>=0&&goal<cells&&from[goal]<10000&&board[goal/n][goal%n]=='.'&&
|
|
183
|
+
goalAge<10&&goal!=start&&depth(goal)>lay+1;
|
|
184
|
+
if(!oldValid){
|
|
185
|
+
goal=-1;double best=-1e20;
|
|
186
|
+
for(int c=0;c<cells;c++)if(from[c]<10000){
|
|
187
|
+
double val=site[c]-1.0*from[c];
|
|
188
|
+
if(val>best){best=val;goal=c;}
|
|
189
|
+
}
|
|
190
|
+
goalAge=0;
|
|
191
|
+
}else goalAge++;
|
|
192
|
+
goalDist=distances(goal<0?start:goal);
|
|
193
|
+
// A lookahead route earns a mild bonus for eventual movement toward the goal.
|
|
194
|
+
for(int c=0;c<cells;c++)if(positionValue[c]>-1e4)
|
|
195
|
+
positionValue[c]+=-.45*min(goalDist[c],30);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Probability-free, conservative first-step collision check. A rival with a
|
|
199
|
+
// possible step into our target can force us to remain where we started.
|
|
200
|
+
bool canBeBlocked(int target){
|
|
201
|
+
int x=target%n,y=target/n;
|
|
202
|
+
for(int i=0;i<p;i++)if(i!=me&&players[i].alive)
|
|
203
|
+
if(abs(players[i].x-x)+abs(players[i].y-y)<=1)return true;
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
int predictLanding(const Forecast& f,int d){
|
|
208
|
+
vector<int> ids,origin,target;
|
|
209
|
+
for(int i=0;i<p;i++)if(players[i].alive){
|
|
210
|
+
int a=pos(players[i]),want=a,dir=4;
|
|
211
|
+
if(i==me)dir=d;
|
|
212
|
+
else if((int)oldPositions.size()==p&&oldPositions[i]>=0){
|
|
213
|
+
int old=oldPositions[i];
|
|
214
|
+
for(int j=0;j<4;j++)if(a==old+dy[j]*n+dx[j])dir=j;
|
|
215
|
+
}
|
|
216
|
+
int x=players[i].x+dx[dir],y=players[i].y+dy[dir];
|
|
217
|
+
if(inside(x,y)){
|
|
218
|
+
int z=at(x,y);
|
|
219
|
+
if(f.open[0][z]&&(!f.occupied[0][z]||z==a))want=z;
|
|
220
|
+
}
|
|
221
|
+
ids.push_back(i);origin.push_back(a);target.push_back(want);
|
|
222
|
+
}
|
|
223
|
+
vector<int> result=target;
|
|
224
|
+
for(int i=0;i<(int)ids.size();i++){
|
|
225
|
+
int duplicates=0;for(int z:target)duplicates+=(z==target[i]);
|
|
226
|
+
if(duplicates>1)result[i]=origin[i];
|
|
227
|
+
}
|
|
228
|
+
bool changed=true;
|
|
229
|
+
while(changed){
|
|
230
|
+
changed=false;
|
|
231
|
+
for(int i=0;i<(int)ids.size();i++)if(result[i]!=origin[i])
|
|
232
|
+
for(int j=0;j<(int)ids.size();j++)if(i!=j&&result[j]==origin[j]&&result[i]==origin[j]){
|
|
233
|
+
result[i]=origin[i];changed=true;break;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
for(int i=0;i<(int)ids.size();i++)if(ids[i]==me)return result[i];
|
|
237
|
+
return pos(players[me]);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
struct Option { int dir=4,place=0;double score=-1e30; };
|
|
241
|
+
|
|
242
|
+
Option decide(){
|
|
243
|
+
horizon=min(10,limitTurn-turnNo);
|
|
244
|
+
if(horizon<1)return {};
|
|
245
|
+
int start=pos(players[me]);
|
|
246
|
+
visits.push_back(start);
|
|
247
|
+
if(visits.size()>40)visits.erase(visits.begin());
|
|
248
|
+
chooseGoal();
|
|
249
|
+
int active=0;bool onBomb=false;
|
|
250
|
+
for(auto b:bombs){if(b.owner==me)active++;if(at(b.x,b.y)==start)onBomb=true;}
|
|
251
|
+
bool mayPlant=active<capacity&&!onBomb;
|
|
252
|
+
Forecast normal=forecast(bombs);
|
|
253
|
+
vector<int> enemyBase(p,0);
|
|
254
|
+
for(int i=0;i<p;i++)if(i!=me&&players[i].alive){
|
|
255
|
+
int enemyStart=pos(players[i]);
|
|
256
|
+
// An opponent may choose its own first move, so union the terminal cells.
|
|
257
|
+
vector<unsigned char> terminal(cells);
|
|
258
|
+
for(int d=0;d<5;d++){
|
|
259
|
+
int x=players[i].x+dx[d],y=players[i].y+dy[d];
|
|
260
|
+
if(!inside(x,y))continue;
|
|
261
|
+
int z=at(x,y);
|
|
262
|
+
if(!normal.open[0][z]||(normal.occupied[0][z]&&z!=enemyStart))continue;
|
|
263
|
+
Reach q=reach(normal,enemyStart,z);
|
|
264
|
+
if(q.life==horizon)enemyBase[i]=max(enemyBase[i],q.count);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
Option best;
|
|
268
|
+
for(int place=0;place<=1;place++){
|
|
269
|
+
if(place&&!mayPlant)continue;
|
|
270
|
+
vector<Bomb> bs=bombs;
|
|
271
|
+
if(place)bs.push_back({me,players[me].x,players[me].y,turnNo+fuseTime});
|
|
272
|
+
Forecast f=place?forecast(bs):normal;
|
|
273
|
+
// A collective current-turn bomb response is possible and often occurs in
|
|
274
|
+
// crowded games. Only nearby rivals whose capacity permits it are included.
|
|
275
|
+
vector<pair<int,int>> threats;
|
|
276
|
+
for(int i=0;i<p;i++)if(i!=me&&players[i].alive){
|
|
277
|
+
int dist=abs(players[i].x-players[me].x)+abs(players[i].y-players[me].y);
|
|
278
|
+
if(dist>7)continue;
|
|
279
|
+
int count=0;bool occupied=false;
|
|
280
|
+
for(auto b:bs){count+=(b.owner==i);occupied|=(b.x==players[i].x&&b.y==players[i].y);}
|
|
281
|
+
if(count<capacity&&!occupied)threats.push_back({dist,i});
|
|
282
|
+
}
|
|
283
|
+
sort(threats.begin(),threats.end());
|
|
284
|
+
vector<Bomb> withThreat=bs;
|
|
285
|
+
for(int j=0;j<(int)threats.size()&&j<3;j++){
|
|
286
|
+
int i=threats[j].second;
|
|
287
|
+
if(players[i].x==players[me].x&&players[i].y==players[me].y)continue;
|
|
288
|
+
withThreat.push_back({i,players[i].x,players[i].y,turnNo+fuseTime});
|
|
289
|
+
}
|
|
290
|
+
Forecast threatened=withThreat.size()>bs.size()?forecast(withThreat):f;
|
|
291
|
+
vector<pair<int,Forecast>> futureThreats;
|
|
292
|
+
if(horizon>=6){
|
|
293
|
+
int considered=0;
|
|
294
|
+
for(auto [distance,i]:threats){
|
|
295
|
+
if(considered++>=2)break;
|
|
296
|
+
for(int d=0;d<5;d++){
|
|
297
|
+
int xx=players[i].x+dx[d],yy=players[i].y+dy[d];
|
|
298
|
+
if(!inside(xx,yy))continue;
|
|
299
|
+
int z=at(xx,yy),old=pos(players[i]);
|
|
300
|
+
if(!f.open[0][z]||!f.safe[0][z]||(f.occupied[0][z]&&z!=old))continue;
|
|
301
|
+
if(!f.open[1][z]||f.occupied[1][z])continue;
|
|
302
|
+
auto other=bs;
|
|
303
|
+
other.push_back({i,xx,yy,turnNo+1+fuseTime,turnNo+1});
|
|
304
|
+
futureThreats.push_back({z,forecast(other)});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
vector<pair<int,Forecast>> delayedThreats;
|
|
309
|
+
if(horizon>=8&&!threats.empty()){
|
|
310
|
+
int i=threats[0].second;
|
|
311
|
+
int old=pos(players[i]);
|
|
312
|
+
vector<unsigned char> afterOne(cells),afterTwo(cells);
|
|
313
|
+
for(int d=0;d<5;d++){
|
|
314
|
+
int x=players[i].x+dx[d],y=players[i].y+dy[d];
|
|
315
|
+
if(!inside(x,y))continue;
|
|
316
|
+
int z=at(x,y);
|
|
317
|
+
if(f.open[0][z]&&f.safe[0][z]&&(!f.occupied[0][z]||z==old))afterOne[z]=1;
|
|
318
|
+
}
|
|
319
|
+
for(int c=0;c<cells;c++)if(afterOne[c])for(int d=0;d<5;d++){
|
|
320
|
+
int x=c%n+dx[d],y=c/n+dy[d];
|
|
321
|
+
if(!inside(x,y))continue;
|
|
322
|
+
int z=at(x,y);
|
|
323
|
+
if(f.open[1][z]&&f.safe[1][z]&&(!f.occupied[1][z]||z==c))afterTwo[z]=1;
|
|
324
|
+
}
|
|
325
|
+
vector<pair<int,int>> sites;
|
|
326
|
+
for(int c=0;c<cells;c++)if(afterTwo[c]&&f.open[2][c]&&!f.occupied[2][c]){
|
|
327
|
+
int dist=abs(c%n-players[me].x)+abs(c/n-players[me].y);
|
|
328
|
+
if(dist<=6)sites.push_back({dist,c});
|
|
329
|
+
}
|
|
330
|
+
sort(sites.begin(),sites.end());
|
|
331
|
+
for(int j=0;j<(int)sites.size()&&j<7;j++){
|
|
332
|
+
int c=sites[j].second;
|
|
333
|
+
auto other=bs;
|
|
334
|
+
other.push_back({i,c%n,c/n,turnNo+2+fuseTime,turnNo+2});
|
|
335
|
+
delayedThreats.push_back({c,forecast(other)});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
double attack=0;
|
|
339
|
+
if(place){
|
|
340
|
+
int crates=cratesHit(start);
|
|
341
|
+
attack=2.7*crates-(p==2?6.0:4.0);
|
|
342
|
+
if(crates&&goal==start)attack+=1.5;
|
|
343
|
+
for(int i=0;i<p;i++)if(i!=me&&players[i].alive&&enemyBase[i]>0){
|
|
344
|
+
int enemyStart=pos(players[i]),remaining=0;
|
|
345
|
+
for(int d=0;d<5;d++){
|
|
346
|
+
int x=players[i].x+dx[d],y=players[i].y+dy[d];
|
|
347
|
+
if(!inside(x,y))continue;
|
|
348
|
+
int z=at(x,y);
|
|
349
|
+
if(!f.open[0][z]||(f.occupied[0][z]&&z!=enemyStart))continue;
|
|
350
|
+
Reach q=reach(f,enemyStart,z);
|
|
351
|
+
if(q.life==horizon)remaining=max(remaining,q.count);
|
|
352
|
+
}
|
|
353
|
+
if(remaining==0)attack+=32.0;
|
|
354
|
+
else attack+=5.0*max(0.0,1.0-(double)remaining/enemyBase[i]);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
for(int d=0;d<5;d++){
|
|
358
|
+
int x=players[me].x+dx[d],y=players[me].y+dy[d];
|
|
359
|
+
if(!inside(x,y))continue;
|
|
360
|
+
int wanted=at(x,y);
|
|
361
|
+
int intended=(f.open[0][wanted]&&(!f.occupied[0][wanted]||wanted==start))?wanted:start;
|
|
362
|
+
int predicted=predictLanding(f,d);
|
|
363
|
+
Reach r=reach(f,start,intended,&positionValue);
|
|
364
|
+
Reach threat=reach(threatened,start,intended);
|
|
365
|
+
bool uncertain=intended!=start&&canBeBlocked(intended);
|
|
366
|
+
Reach blocked;
|
|
367
|
+
if(uncertain)blocked=reach(f,start,start);
|
|
368
|
+
double effectiveLife=r.life;
|
|
369
|
+
if(predicted!=intended){
|
|
370
|
+
Reach expected=reach(f,start,predicted);
|
|
371
|
+
effectiveLife=.65*r.life+.35*expected.life;
|
|
372
|
+
}else if(uncertain)effectiveLife=.85*r.life+.15*blocked.life;
|
|
373
|
+
double score=1000.0*effectiveLife;
|
|
374
|
+
if(r.life==horizon){
|
|
375
|
+
score+=attack;
|
|
376
|
+
score+=2.2*log1p(r.count);
|
|
377
|
+
score+=1.35*r.mobility;
|
|
378
|
+
score+=.2*r.best;
|
|
379
|
+
score-=1.25*min(goalDist[intended],40);
|
|
380
|
+
score-=1.5*visitCost(intended);
|
|
381
|
+
score+=.22*positionValue[intended];
|
|
382
|
+
score+=.15*depth(intended);
|
|
383
|
+
if(intended==start)score-=.9;
|
|
384
|
+
}
|
|
385
|
+
if(threat.life<horizon)score-=35+12*(horizon-threat.life);
|
|
386
|
+
else score+=1.2*log1p(threat.count);
|
|
387
|
+
int worstFuture=horizon;
|
|
388
|
+
for(auto& [site,scenario]:futureThreats){
|
|
389
|
+
// The rival cannot occupy our successful landing and plant there next turn.
|
|
390
|
+
if(site==intended&&site!=start)continue;
|
|
391
|
+
worstFuture=min(worstFuture,reach(scenario,start,intended).life);
|
|
392
|
+
}
|
|
393
|
+
if(worstFuture<horizon)score-=(place?1.35:1.0)*(25+19*(horizon-worstFuture));
|
|
394
|
+
int worstDelayed=horizon;
|
|
395
|
+
for(auto& [site,scenario]:delayedThreats)
|
|
396
|
+
worstDelayed=min(worstDelayed,reach(scenario,start,intended).life);
|
|
397
|
+
if(worstDelayed<horizon)score-=(place?0.85:0.6)*(20+14*(horizon-worstDelayed));
|
|
398
|
+
if(uncertain&&blocked.life==r.life)score-=2.0;
|
|
399
|
+
if(predicted==start&&intended!=start)score-=1.0;
|
|
400
|
+
if(place&&r.life<horizon)score-=100;
|
|
401
|
+
// Stable tie breaking avoids dithering caused by exact score ties.
|
|
402
|
+
score-=0.0001*((turnNo+d+place*3)%7);
|
|
403
|
+
if(score>best.score)best={d,place,score};
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if(best.place)goal=-1;
|
|
407
|
+
oldPositions.resize(p);
|
|
408
|
+
for(int i=0;i<p;i++)oldPositions[i]=players[i].alive?pos(players[i]):-1;
|
|
409
|
+
return best;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
bool readTurn(){
|
|
413
|
+
string word;
|
|
414
|
+
if(!(cin>>word>>turnNo))return false;
|
|
415
|
+
if(word!="TURN")return false;
|
|
416
|
+
cin>>word;
|
|
417
|
+
for(auto& row:board)cin>>row;
|
|
418
|
+
for(int i=0;i<p;i++){
|
|
419
|
+
int id;cin>>word>>id;
|
|
420
|
+
cin>>players[id].x>>players[id].y>>players[id].alive;
|
|
421
|
+
}
|
|
422
|
+
int count;cin>>word>>count;
|
|
423
|
+
bombs.resize(count);
|
|
424
|
+
for(auto& b:bombs)cin>>word>>b.owner>>b.x>>b.y>>b.at;
|
|
425
|
+
cin>>word>>count;flames.resize(count);
|
|
426
|
+
for(auto& f:flames)cin>>word>>f.x>>f.y>>f.last;
|
|
427
|
+
while(cin>>word){
|
|
428
|
+
if(word=="END")return true;
|
|
429
|
+
string rest;getline(cin,rest);
|
|
430
|
+
}
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
int main(){
|
|
435
|
+
ios::sync_with_stdio(false);cin.tie(nullptr);
|
|
436
|
+
string init;
|
|
437
|
+
if(!(cin>>init>>n>>p>>me>>limitTurn>>fuseTime>>radius>>capacity>>fireTurns>>shrinkStart>>shrinkEvery))return 0;
|
|
438
|
+
cells=n*n;board.resize(n);players.resize(p);
|
|
439
|
+
while(readTurn()){
|
|
440
|
+
Option a=decide();
|
|
441
|
+
cout<<turnNo<<' '<<directions[a.dir]<<' '<<a.place<<'\n'<<flush;
|
|
442
|
+
}
|
|
443
|
+
return 0;
|
|
444
|
+
}
|