Spaces:
Running
feat(scenario): def-pre-position-mobile-reserve — central reserve reacts to any flank (military reserve doctrine anchor)
Browse filesREASONING capability — Group C (Wave-5) defence positioning. A mobile
armoured reserve is pre-staged at the CENTRE equidistant from candidate
flanks; the reserve MUST move FORWARD to the localised threat lane(s)
to satisfy the lane-mouth intercept clause(s). Stall, commit-NORTH (on
multi-flank levels), and commit-SOUTH all LOSE on the position clause
even when auto-engagement at the centre clears the kill bar; only an
active split / staggered forward send WINS.
Discriminators:
- easy: ONE rush band (NORTH). Win requires ≥2 tanks in (60,12)
r=10. Stall fails the zone clause; commit-N is the intended
single-direction play and WINS.
- medium: TWO bands (N + S, both always present per CLAUDE.md
enemy-spawn-point semantics). Win requires `all_of` (N r=12, S
r=12). Any single-flank commit empties the opposite zone → LOSS.
- hard: THREE bands (N + S + E head-on). Win requires `all_of`
(N r=10, CENTRE r=12, S r=10) AND units_lost_lte:2. Two agent
spawn_point groups (centre column x=40 vs x=50) round-robin
per seed so the doctrine, not the cell, must generalise.
Real-world anchors:
- Military 'general reserve' / 'covering force' doctrine
- Chess-piece centralization (centralised piece reaches all flanks)
- Rapid-response force / QRF / on-call SRE staging at a hub
- MicroRTS reactive defence from centre
Validation: tests/test_def_pre_position_mobile_reserve.py — 20 tests
(structural + solvency + no-cheat) all pass deterministically on the
Rust engine; bar holds every level + every hard seed.
Hard-tier UPGRADED entry already in main from the Wave-5 salvage.
|
@@ -0,0 +1,381 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
#
|
| 3 |
+
# REASONING capability — Group C "defence positioning" seed: pre-
|
| 4 |
+
# positioning a MOBILE armoured reserve at the CENTRE of the
|
| 5 |
+
# engagement zone so it can MOVE FORWARD and intercept rushers at
|
| 6 |
+
# their lane mouth. Sibling of `def-position-expected-direction`
|
| 7 |
+
# (commit pbox to the *expected* flank; build-based) and
|
| 8 |
+
# `def-surprise-flank-react` (replan when the expected flank was
|
| 9 |
+
# wrong). This pack is the COMBAT-ONLY counterpart: no build tools —
|
| 10 |
+
# the model only moves an armoured reserve, and the decision is
|
| 11 |
+
# WHERE to commit it forward.
|
| 12 |
+
#
|
| 13 |
+
# Real-world anchors:
|
| 14 |
+
# - Military "general reserve" / "covering force" doctrine: the
|
| 15 |
+
# reserve is held centrally, uncommitted, until the threat
|
| 16 |
+
# direction localises; then it commits FORWARD, as a unit, toward
|
| 17 |
+
# the lane that materialised.
|
| 18 |
+
# - Chess-piece centralization: a centralised knight/queen REACHES
|
| 19 |
+
# more squares than a flank-committed one. A centralised reserve
|
| 20 |
+
# can REACH either flank in equal time; a flank-committed reserve
|
| 21 |
+
# cannot reach the opposite flank fast enough.
|
| 22 |
+
# - Rapid-response force doctrine (fire brigade, QRF, on-call SRE):
|
| 23 |
+
# responders are staged at a hub; on alert they MOVE OUT to the
|
| 24 |
+
# localised site. Staying at the hub satisfies no objective.
|
| 25 |
+
# - MicroRTS reactive defence from centre.
|
| 26 |
+
#
|
| 27 |
+
# DISCRIMINATIONS (the bar — every lazy / wrong-commit play LOSES,
|
| 28 |
+
# the intended centre-then-react play WINS):
|
| 29 |
+
#
|
| 30 |
+
# • stall (observe only): the stance:3 reserve auto-engages the
|
| 31 |
+
# rush when it closes to cannon range and racks up some kills,
|
| 32 |
+
# but the reserve NEVER MOVES OUT of its starting cluster. The
|
| 33 |
+
# FORWARD-zone clause (`units_in_region_gte` at the lane-mouth
|
| 34 |
+
# intercept point) is therefore never satisfied → LOSS on the
|
| 35 |
+
# position clause even when the kill count is met. The
|
| 36 |
+
# `after_ticks: 2401` fail bites at max_turns either way.
|
| 37 |
+
#
|
| 38 |
+
# • commit-NORTH (whole reserve sent north on turn 1): on easy
|
| 39 |
+
# (rush IS from NORTH) this matches the lane and satisfies the
|
| 40 |
+
# N forward zone → WIN. On medium (BOTH flanks active) only the
|
| 41 |
+
# N zone is satisfied — the S forward-zone clause fails → LOSS.
|
| 42 |
+
# On hard (three flanks N/S/E active) only the N zone is
|
| 43 |
+
# satisfied → S and E clauses fail → LOSS.
|
| 44 |
+
#
|
| 45 |
+
# • commit-SOUTH: symmetric to commit-NORTH — LOSS on easy
|
| 46 |
+
# (NORTH-only rush; S zone is wrong + N zone empty) and LOSS on
|
| 47 |
+
# medium/hard (other flanks unaddressed).
|
| 48 |
+
#
|
| 49 |
+
# • intended centre-then-react: on easy, send the whole reserve
|
| 50 |
+
# toward the spotted N band — tanks reach the N forward zone
|
| 51 |
+
# (60,12) r=10. On medium, SPLIT the reserve (or stagger) so
|
| 52 |
+
# ≥1 tank lands in EACH of the N (60,14) r=12 and S (60,26)
|
| 53 |
+
# r=12 forward zones. On hard, split THREE ways so ≥1 tank
|
| 54 |
+
# lands in EACH of the N (60,12) r=10, CENTRE (65,20) r=12,
|
| 55 |
+
# and S (60,28) r=10 forward zones. WIN on every seed.
|
| 56 |
+
#
|
| 57 |
+
# ENGINE FACTS used (CLAUDE.md / SCENARIO_QUALITY.md):
|
| 58 |
+
# - `rusher` bot concentrates the band on the agent CENTROID every
|
| 59 |
+
# ~8 ticks (openra-sim/src/scripted_bot.rs::Rusher) — band drives
|
| 60 |
+
# straight at the nearest agent mass.
|
| 61 |
+
# - Enemy actors with NO spawn_point ALWAYS place regardless of
|
| 62 |
+
# agent spawn group (CLAUDE.md). On medium/hard we DECLARE
|
| 63 |
+
# multiple bands and they BOTH/ALL place every seed. The
|
| 64 |
+
# "react to either flank" capability is enforced by having
|
| 65 |
+
# ALL candidate flanks active every seed — strictly the harder
|
| 66 |
+
# test than a per-seed flank flip.
|
| 67 |
+
# - Inert enemy `fact` marker far east (anti-DRAW): without a
|
| 68 |
+
# persistent enemy actor the engine auto-`done`s on enemy-elim
|
| 69 |
+
# before the win/fail evaluator runs.
|
| 70 |
+
# - `enemy_unit_spotted` interrupt → reserve re-decides the instant
|
| 71 |
+
# a rusher band becomes visible.
|
| 72 |
+
# - `own_unit_destroyed` interrupt → re-decide on tank loss.
|
| 73 |
+
# - `units_in_region_gte: {x, y, radius, n}` — load-bearing
|
| 74 |
+
# position clause: forces the reserve to MOVE FORWARD (not just
|
| 75 |
+
# auto-defend at the centre).
|
| 76 |
+
# - 2tnk vs e1: tanks dominate per-shot (1-shot e1); e1 vs 2tnk has
|
| 77 |
+
# low damage (CLAUDE.md / combat-focus-fire-priority). So a
|
| 78 |
+
# stance:3 reserve auto-wipes an e1-only rush without losing
|
| 79 |
+
# tanks. The discriminator is POSITION, not kill economy — the
|
| 80 |
+
# stall reserve passes the kill bar but FAILS the position bar.
|
| 81 |
+
# - Tick budget: ~90 ticks/turn fixed-step, ~60 ticks/turn in
|
| 82 |
+
# interrupt mode (every fired interrupt cuts the step short).
|
| 83 |
+
# max_turns 50 → reachable tick ≈ 3000 in interrupt mode;
|
| 84 |
+
# `within_ticks: 2400` and `after_ticks: 2401` are both reachable
|
| 85 |
+
# well inside max_turns so stall hits the deadline as a real
|
| 86 |
+
# LOSS (not a draw degeneracy).
|
| 87 |
+
#
|
| 88 |
+
# Validate (no model / no network):
|
| 89 |
+
# python3 -m openra_bench.scenarios.validate \
|
| 90 |
+
# openra_bench/scenarios/packs/def-pre-position-mobile-reserve.yaml
|
| 91 |
+
|
| 92 |
+
meta:
|
| 93 |
+
id: def-pre-position-mobile-reserve
|
| 94 |
+
title: 'Central Reserve — Stage Mobile Force at Centre, Move Out to Intercept'
|
| 95 |
+
capability: reasoning
|
| 96 |
+
real_world_meaning: >
|
| 97 |
+
A rush is incoming, but the flank it will arrive from is uncertain
|
| 98 |
+
at decision time. A small mobile armoured reserve is pre-staged
|
| 99 |
+
at the centre of the engagement zone — equidistant from both
|
| 100 |
+
candidate flanks. The reserve MUST move OUT of the centre toward
|
| 101 |
+
the localised threat lane(s) to intercept the rush before it
|
| 102 |
+
reaches the construction yard. Pre-committing to one flank wins
|
| 103 |
+
only when the rush arrives on that flank and LOSES otherwise
|
| 104 |
+
(the reserve cannot pivot back in time); holding passively at
|
| 105 |
+
the centre lets the auto-engagement kill some attackers but
|
| 106 |
+
satisfies no forward-zone objective. The canonical answer is
|
| 107 |
+
centralisation + forward commitment — military "general reserve"
|
| 108 |
+
/ chess centralization doctrine.
|
| 109 |
+
robotics_analogue: >
|
| 110 |
+
Quick-reaction force / on-call incident responder: the responder
|
| 111 |
+
is stationed at a hub equidistant from candidate incident sites,
|
| 112 |
+
not committed to any one site in advance. When an alert localises
|
| 113 |
+
the incident, the responder DEPLOYS FORWARD to that site —
|
| 114 |
+
staying at the hub or committing in advance to the wrong site
|
| 115 |
+
both fail the response SLA.
|
| 116 |
+
benchmark_anchor:
|
| 117 |
+
- "military reserve doctrine (central reserve responds to any flank)"
|
| 118 |
+
- "chess-piece centralization principle"
|
| 119 |
+
- "rapid-response force doctrine"
|
| 120 |
+
- "MicroRTS reactive defense from centre"
|
| 121 |
+
author: openra-bench
|
| 122 |
+
|
| 123 |
+
# rush-hour-arena: 128×40 playable. Agent base at the west (fact at
|
| 124 |
+
# x=10), rush spawns near the eastern lane mouths (x=80). The reserve
|
| 125 |
+
# stages at x=40 — the geometric centre of the engagement zone,
|
| 126 |
+
# equidistant in y from north (y=10) and south (y=30) flanks.
|
| 127 |
+
base_map: rush-hour-arena
|
| 128 |
+
starting_cash: 0
|
| 129 |
+
|
| 130 |
+
base:
|
| 131 |
+
agent:
|
| 132 |
+
faction: allies
|
| 133 |
+
cash: 0
|
| 134 |
+
enemy:
|
| 135 |
+
faction: soviet
|
| 136 |
+
cash: 0
|
| 137 |
+
bot_type: rusher
|
| 138 |
+
# Combat-only toolset (NO build / NO harvest): the test is reserve
|
| 139 |
+
# POSITIONING + COMMITMENT, not production.
|
| 140 |
+
tools:
|
| 141 |
+
- observe
|
| 142 |
+
- move_units
|
| 143 |
+
- attack_unit
|
| 144 |
+
- attack_move
|
| 145 |
+
- stop
|
| 146 |
+
planning: true
|
| 147 |
+
# React the INSTANT a rusher unit is spotted or a reserve tank is
|
| 148 |
+
# lost — the centre-then-react doctrine needs the flank-localisation
|
| 149 |
+
# alert to bite immediately, not on the next decision boundary.
|
| 150 |
+
interrupts:
|
| 151 |
+
enemy_unit_spotted: true
|
| 152 |
+
own_unit_destroyed: true
|
| 153 |
+
termination:
|
| 154 |
+
max_ticks: 6000
|
| 155 |
+
actors: []
|
| 156 |
+
|
| 157 |
+
levels:
|
| 158 |
+
# ── EASY ─────────────────────────────────────────────────────────
|
| 159 |
+
# Bare reserve-MOVE skill: ONE rush band, FIXED direction (NORTH
|
| 160 |
+
# y=10 every seed). The capability is "move the reserve OUT to
|
| 161 |
+
# intercept the rush at its lane mouth". stance:3 tanks auto-engage
|
| 162 |
+
# when the band arrives at the centre (stall racks up kills via
|
| 163 |
+
# auto-defence), but the FORWARD-zone clause (units_in_region_gte
|
| 164 |
+
# at the NORTH-flank intercept point) is the load-bearing
|
| 165 |
+
# discriminator: stall keeps tanks at (40,20) → outside the
|
| 166 |
+
# (60,12) r=10 zone → LOSS.
|
| 167 |
+
# max_turns 50 → reachable tick ~3000 in interrupt mode, ~4503
|
| 168 |
+
# fixed-step; `after_ticks: 2401` bites well before max_turns.
|
| 169 |
+
easy:
|
| 170 |
+
description: >
|
| 171 |
+
Your construction yard (fact) sits at the west edge (10,20). A
|
| 172 |
+
mobile armoured reserve of 4 medium tanks (2tnk) is staged at
|
| 173 |
+
the CENTRE (40,20). A rifle-infantry rush is incoming from the
|
| 174 |
+
NORTH (spawn at (80,10)) and will drive straight at the
|
| 175 |
+
centroid of your forces. Move the reserve FORWARD toward the
|
| 176 |
+
NORTH lane mouth to intercept the rush — at least 2 tanks must
|
| 177 |
+
be within radius 10 of the NORTH-flank intercept point (60,12)
|
| 178 |
+
at win time AND you must destroy ≥4 of the rushers AND keep
|
| 179 |
+
≥1 tank alive AND finish before tick 2400. Holding the reserve
|
| 180 |
+
at the centre never satisfies the forward-zone clause;
|
| 181 |
+
committing south sends the tanks away from the threat (no
|
| 182 |
+
forward-zone satisfaction); stalling loses on the clock.
|
| 183 |
+
overrides:
|
| 184 |
+
actors:
|
| 185 |
+
# Agent construction yard — WEST edge, the rusher target.
|
| 186 |
+
- {type: fact, owner: agent, position: [10, 20]}
|
| 187 |
+
# Mobile reserve — 4 medium tanks at CENTRE (40,20).
|
| 188 |
+
# stance:3 (AttackAnything) — auto-engages enemies in vision
|
| 189 |
+
# range. The discriminator is NOT auto-engagement (engine
|
| 190 |
+
# handles that) but the FORWARD-ZONE clause: a passive
|
| 191 |
+
# reserve at (40,20) never reaches (60,12) r=10, so stall
|
| 192 |
+
# fails the position clause even when auto-defence wins on
|
| 193 |
+
# kill count.
|
| 194 |
+
- {type: 2tnk, owner: agent, position: [40, 19], stance: 3}
|
| 195 |
+
- {type: 2tnk, owner: agent, position: [40, 20], stance: 3}
|
| 196 |
+
- {type: 2tnk, owner: agent, position: [40, 21], stance: 3}
|
| 197 |
+
- {type: 2tnk, owner: agent, position: [41, 20], stance: 3}
|
| 198 |
+
# NORTH rush band — 6× e1. e1-only so 4 tanks dominate the
|
| 199 |
+
# engagement (per CLAUDE.md / combat-focus-fire-priority:
|
| 200 |
+
# e1 vs 2tnk has very low damage). 6 enemies makes the
|
| 201 |
+
# units_killed_gte:4 bar comfortably achievable.
|
| 202 |
+
- {type: e1, owner: enemy, position: [80, 10], stance: 3, count: 6}
|
| 203 |
+
# Inert enemy `fact` marker far east (anti-DRAW): without it
|
| 204 |
+
# the engine auto-`done`s on enemy-elim before the win/fail
|
| 205 |
+
# evaluator runs (CLAUDE.md footgun).
|
| 206 |
+
- {type: fact, owner: enemy, position: [120, 20]}
|
| 207 |
+
win_condition:
|
| 208 |
+
all_of:
|
| 209 |
+
- {units_killed_gte: 4}
|
| 210 |
+
- {own_units_gte: 1}
|
| 211 |
+
# FORWARD-zone clause: ≥2 tanks within radius 10 of the
|
| 212 |
+
# NORTH-flank intercept point (60,12). Stall keeps tanks at
|
| 213 |
+
# (40,20) — distance sqrt(20²+8²) ≈ 21.5 > 10 → clause
|
| 214 |
+
# fails. Active forward intercept (attack_move toward
|
| 215 |
+
# (60,12)) puts the surviving tanks inside the zone.
|
| 216 |
+
- {units_in_region_gte: {x: 60, y: 12, radius: 10, n: 2}}
|
| 217 |
+
- {within_ticks: 2400}
|
| 218 |
+
fail_condition:
|
| 219 |
+
any_of:
|
| 220 |
+
- {after_ticks: 2401}
|
| 221 |
+
- {not: {has_building: fact}}
|
| 222 |
+
- {not: {own_units_gte: 1}}
|
| 223 |
+
max_turns: 50
|
| 224 |
+
|
| 225 |
+
# ── MEDIUM ───────────────────────────────────────────────────────
|
| 226 |
+
# +1 controlled variable: TWO simultaneous bands from BOTH flanks
|
| 227 |
+
# (NORTH y=10 and SOUTH y=30 — engine constraint per CLAUDE.md:
|
| 228 |
+
# enemy actors don't honour spawn_point, so we encode "either flank
|
| 229 |
+
# possible" as "BOTH flanks active every seed", which is strictly
|
| 230 |
+
# the harder test). The win clause requires `all_of` BOTH forward
|
| 231 |
+
# zones to hold ≥1 tank — the reserve MUST SPLIT or stagger sends
|
| 232 |
+
# so both lanes are addressed. A commit-NORTH puts 0 tanks in the
|
| 233 |
+
# S zone → S clause fails → LOSS. Stall puts everyone at the
|
| 234 |
+
# centre → both clauses fail.
|
| 235 |
+
medium:
|
| 236 |
+
description: >
|
| 237 |
+
Your construction yard (fact) sits at the west edge (10,20). A
|
| 238 |
+
mobile armoured reserve of 6 medium tanks (2tnk) is staged at
|
| 239 |
+
the CENTRE (40,20). Two rush bands are incoming — one from the
|
| 240 |
+
NORTH (spawn at (80,10)) and one from the SOUTH (spawn at
|
| 241 |
+
(80,30)) — and both drive at the centroid of your forces.
|
| 242 |
+
SPLIT or STAGGER the reserve so BOTH flanks are addressed —
|
| 243 |
+
at least 1 tank within radius 12 of the NORTH intercept
|
| 244 |
+
(60,14) AND at least 1 tank within radius 12 of the SOUTH
|
| 245 |
+
intercept (60,26) at win time, AND destroy ≥6 rushers AND
|
| 246 |
+
keep ≥2 tanks alive AND keep the fact standing, AND finish
|
| 247 |
+
before tick 2400. Holding the reserve at the centre never
|
| 248 |
+
satisfies either forward-zone clause; committing the WHOLE
|
| 249 |
+
reserve to ONE flank puts 0 tanks in the opposite zone (the
|
| 250 |
+
other-flank clause fails); only an active split / staggered
|
| 251 |
+
send to BOTH flanks wins.
|
| 252 |
+
overrides:
|
| 253 |
+
actors:
|
| 254 |
+
# Agent fact — west, the rusher target.
|
| 255 |
+
- {type: fact, owner: agent, position: [10, 20]}
|
| 256 |
+
# 6× 2tnk mobile reserve at CENTRE — two extra tanks over
|
| 257 |
+
# easy to make the 2-way split tractable (3 to each flank
|
| 258 |
+
# is the canonical split; 2 to each flank if pursuing centre
|
| 259 |
+
# micro). stance:3 as on easy.
|
| 260 |
+
- {type: 2tnk, owner: agent, position: [40, 19], stance: 3}
|
| 261 |
+
- {type: 2tnk, owner: agent, position: [40, 20], stance: 3}
|
| 262 |
+
- {type: 2tnk, owner: agent, position: [40, 21], stance: 3}
|
| 263 |
+
- {type: 2tnk, owner: agent, position: [41, 19], stance: 3}
|
| 264 |
+
- {type: 2tnk, owner: agent, position: [41, 20], stance: 3}
|
| 265 |
+
- {type: 2tnk, owner: agent, position: [41, 21], stance: 3}
|
| 266 |
+
# NORTH rush band — 5× e1.
|
| 267 |
+
- {type: e1, owner: enemy, position: [80, 10], stance: 3, count: 5}
|
| 268 |
+
# SOUTH rush band — 5× e1. Total 10 e1 across both bands.
|
| 269 |
+
# The position-clause discriminator (BOTH N-zone AND S-zone
|
| 270 |
+
# must hold ≥1 tank) is the load-bearing test: a wrong-flank
|
| 271 |
+
# commit puts 0 tanks in the opposite zone → clause fails.
|
| 272 |
+
- {type: e1, owner: enemy, position: [80, 30], stance: 3, count: 5}
|
| 273 |
+
# Inert enemy `fact` marker far east (anti-DRAW).
|
| 274 |
+
- {type: fact, owner: enemy, position: [120, 20]}
|
| 275 |
+
win_condition:
|
| 276 |
+
all_of:
|
| 277 |
+
- {units_killed_gte: 6}
|
| 278 |
+
- {own_units_gte: 2}
|
| 279 |
+
# BOTH forward-flank zones must hold ≥1 tank — the reserve
|
| 280 |
+
# MUST SPLIT (or stagger) to address both flanks. A
|
| 281 |
+
# commit-NORTH policy puts all tanks in the N zone (0 in S
|
| 282 |
+
# zone) → S clause fails → LOSS. Stall (everyone at centre)
|
| 283 |
+
# fails both zones.
|
| 284 |
+
- {units_in_region_gte: {x: 60, y: 14, radius: 12, n: 1}}
|
| 285 |
+
- {units_in_region_gte: {x: 60, y: 26, radius: 12, n: 1}}
|
| 286 |
+
- {within_ticks: 2400}
|
| 287 |
+
fail_condition:
|
| 288 |
+
any_of:
|
| 289 |
+
- {after_ticks: 2401}
|
| 290 |
+
- {not: {has_building: fact}}
|
| 291 |
+
- {not: {own_units_gte: 1}}
|
| 292 |
+
max_turns: 50
|
| 293 |
+
|
| 294 |
+
# ── HARD ─────────────────────────────────────────────────────────
|
| 295 |
+
# +1 controlled variable on top of medium: THREE rush directions
|
| 296 |
+
# (N y=10, S y=30, E y=20 head-on) AND a strict attrition cap
|
| 297 |
+
# (units_lost_lte: 2 — at most 2 tanks lost) AND ≥2 agent
|
| 298 |
+
# spawn_point groups so the reserve's starting CELL varies per
|
| 299 |
+
# seed (centre column x=40 vs x=50 — both remain equidistant
|
| 300 |
+
# from N/S flanks; the centre-then-react DOCTRINE generalises,
|
| 301 |
+
# a memorised cell does not). Kill bar 6 — high enough that no
|
| 302 |
+
# single-flank commit kills enough alone but low enough that an
|
| 303 |
+
# active three-way split clears it comfortably. The win clause
|
| 304 |
+
# requires `all_of` THREE forward zones (N + CENTRE + S) — the
|
| 305 |
+
# reserve must split three ways or stagger across all three lanes.
|
| 306 |
+
# Same clock; same tick-aligned fail.
|
| 307 |
+
hard:
|
| 308 |
+
description: >
|
| 309 |
+
Your construction yard (fact) sits at the west edge (10,20). A
|
| 310 |
+
mobile armoured reserve of 6 medium tanks (2tnk) is staged at
|
| 311 |
+
the CENTRE of the arena — a seed-chosen central cell (the
|
| 312 |
+
reserve's exact column varies per seed so a memorised opening
|
| 313 |
+
cannot generalise; the central reserve DOCTRINE still applies
|
| 314 |
+
from either start). Three rush bands are incoming — NORTH
|
| 315 |
+
(y=10), SOUTH (y=30), and EAST (y=20, head-on) — and all
|
| 316 |
+
drive at the centroid of your forces. Win requires: destroy
|
| 317 |
+
≥6 rushers AND keep ≥2 tanks alive AND lose AT MOST 2 tanks
|
| 318 |
+
AND at least 1 tank within radius 10 of the NORTH intercept
|
| 319 |
+
(60,12) AND at least 1 tank within radius 12 of the CENTRE
|
| 320 |
+
intercept (65,20) AND at least 1 tank within radius 10 of
|
| 321 |
+
the SOUTH intercept (60,28) at win time AND keep the fact
|
| 322 |
+
standing AND finish before tick 2400. Holding the reserve at
|
| 323 |
+
the centre fails the N and S clauses; pre-committing to a
|
| 324 |
+
single flank fails the other two; only an active three-way
|
| 325 |
+
push wins.
|
| 326 |
+
overrides:
|
| 327 |
+
actors:
|
| 328 |
+
# Agent fact — duplicated across BOTH spawn_point groups at
|
| 329 |
+
# the SAME cell (CLAUDE.md: if ANY agent actor declares
|
| 330 |
+
# spawn_point, every agent actor WITHOUT spawn_point is
|
| 331 |
+
# filtered OUT — so we tag every agent actor).
|
| 332 |
+
- {type: fact, owner: agent, position: [10, 20], spawn_point: 0}
|
| 333 |
+
- {type: fact, owner: agent, position: [10, 20], spawn_point: 1}
|
| 334 |
+
# spawn_point 0 — reserve at centre column x=40.
|
| 335 |
+
- {type: 2tnk, owner: agent, position: [40, 19], stance: 3, spawn_point: 0}
|
| 336 |
+
- {type: 2tnk, owner: agent, position: [40, 20], stance: 3, spawn_point: 0}
|
| 337 |
+
- {type: 2tnk, owner: agent, position: [40, 21], stance: 3, spawn_point: 0}
|
| 338 |
+
- {type: 2tnk, owner: agent, position: [41, 19], stance: 3, spawn_point: 0}
|
| 339 |
+
- {type: 2tnk, owner: agent, position: [41, 20], stance: 3, spawn_point: 0}
|
| 340 |
+
- {type: 2tnk, owner: agent, position: [41, 21], stance: 3, spawn_point: 0}
|
| 341 |
+
# spawn_point 1 — reserve at centre column x=50 (alternate
|
| 342 |
+
# central staging; equidistant from N/S flanks and between
|
| 343 |
+
# fact and rush spawn). A memorised "stage at (40,20)" cell
|
| 344 |
+
# cannot generalise; the doctrine (centre, react) does.
|
| 345 |
+
- {type: 2tnk, owner: agent, position: [50, 19], stance: 3, spawn_point: 1}
|
| 346 |
+
- {type: 2tnk, owner: agent, position: [50, 20], stance: 3, spawn_point: 1}
|
| 347 |
+
- {type: 2tnk, owner: agent, position: [50, 21], stance: 3, spawn_point: 1}
|
| 348 |
+
- {type: 2tnk, owner: agent, position: [51, 19], stance: 3, spawn_point: 1}
|
| 349 |
+
- {type: 2tnk, owner: agent, position: [51, 20], stance: 3, spawn_point: 1}
|
| 350 |
+
- {type: 2tnk, owner: agent, position: [51, 21], stance: 3, spawn_point: 1}
|
| 351 |
+
# THREE rush bands — N (y=10), S (y=30), E (y=20 head-on).
|
| 352 |
+
# All ALWAYS placed (enemy actors don't honour spawn_point).
|
| 353 |
+
# Total 12 e1 — kill bar 6 is achievable with active forward
|
| 354 |
+
# intercepts on all three lanes.
|
| 355 |
+
- {type: e1, owner: enemy, position: [80, 10], stance: 3, count: 4}
|
| 356 |
+
- {type: e1, owner: enemy, position: [80, 30], stance: 3, count: 4}
|
| 357 |
+
- {type: e1, owner: enemy, position: [90, 20], stance: 3, count: 4}
|
| 358 |
+
# Inert enemy `fact` marker far east (anti-DRAW). Placed
|
| 359 |
+
# off-axis (y=2) so the head-on east band doesn't path
|
| 360 |
+
# through it.
|
| 361 |
+
- {type: fact, owner: enemy, position: [120, 2]}
|
| 362 |
+
win_condition:
|
| 363 |
+
all_of:
|
| 364 |
+
- {units_killed_gte: 6}
|
| 365 |
+
- {own_units_gte: 2}
|
| 366 |
+
- {units_lost_lte: 2}
|
| 367 |
+
# THREE forward zones — each must hold ≥1 tank. The reserve
|
| 368 |
+
# must split three ways (2/2/2) or stagger sends across all
|
| 369 |
+
# three lanes. Holding at centre fails N and S; committing
|
| 370 |
+
# to one flank fails the other two.
|
| 371 |
+
- {units_in_region_gte: {x: 60, y: 12, radius: 10, n: 1}}
|
| 372 |
+
- {units_in_region_gte: {x: 65, y: 20, radius: 12, n: 1}}
|
| 373 |
+
- {units_in_region_gte: {x: 60, y: 28, radius: 10, n: 1}}
|
| 374 |
+
- {within_ticks: 2400}
|
| 375 |
+
fail_condition:
|
| 376 |
+
any_of:
|
| 377 |
+
- {after_ticks: 2401}
|
| 378 |
+
- {not: {has_building: fact}}
|
| 379 |
+
- {not: {own_units_gte: 1}}
|
| 380 |
+
- {not: {units_lost_lte: 2}}
|
| 381 |
+
max_turns: 50
|
|
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""def-pre-position-mobile-reserve scenario pack, full loop on Rust.
|
| 2 |
+
|
| 3 |
+
REASONING capability — CENTRAL MOBILE RESERVE that must move OUT of
|
| 4 |
+
the centre to intercept rushers on whichever flank materialises. The
|
| 5 |
+
load-bearing predicate is `units_in_region_gte` at the FORWARD
|
| 6 |
+
intercept zone(s): a passive central reserve auto-engages the rush
|
| 7 |
+
when it closes to cannon range (the engine handles the kill economy)
|
| 8 |
+
but never SATISFIES the forward-zone clause; only an explicit
|
| 9 |
+
forward `attack_move` to the lane mouth puts a tank in the zone.
|
| 10 |
+
|
| 11 |
+
The bar:
|
| 12 |
+
|
| 13 |
+
* `units_in_region_gte: {x, y, radius, n: 1..2}` at the lane-mouth
|
| 14 |
+
intercept point(s) ⇒ a stall keeps tanks at the centre → outside
|
| 15 |
+
the zone → LOSS even when the kill bar is met.
|
| 16 |
+
* On medium: BOTH a N forward zone AND a S forward zone ⇒ the
|
| 17 |
+
reserve must SPLIT or stagger; committing the whole reserve to one
|
| 18 |
+
flank leaves the opposite zone empty → LOSS.
|
| 19 |
+
* On hard: THREE forward zones (N, CENTRE, S) ⇒ the reserve must
|
| 20 |
+
split three ways; any single-flank commit fails ≥2 zones.
|
| 21 |
+
* `units_killed_gte: N` ⇒ a real engagement bar (matched to the
|
| 22 |
+
total band size so an active intercept clears it comfortably).
|
| 23 |
+
* `units_lost_lte: 2` (hard only) ⇒ attrition cap so a sloppy
|
| 24 |
+
intercept that bleeds the reserve busts even if the position
|
| 25 |
+
clauses hold.
|
| 26 |
+
* `within_ticks: 2400` paired with `after_ticks: 2401` ⇒ a non-
|
| 27 |
+
finisher is a real reachable timeout LOSS, never a draw.
|
| 28 |
+
|
| 29 |
+
These tests prove deterministically (no model / no network):
|
| 30 |
+
|
| 31 |
+
* the intended forward-intercept play WINS every level + every
|
| 32 |
+
hard seed;
|
| 33 |
+
* stall, commit-NORTH, and commit-SOUTH all LOSE on the levels
|
| 34 |
+
where they don't match the intended capability (a real LOSS, not
|
| 35 |
+
a draw);
|
| 36 |
+
* the hard tier defines ≥2 spawn_point groups so a memorised
|
| 37 |
+
centre cell cannot generalise.
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
from __future__ import annotations
|
| 41 |
+
|
| 42 |
+
import pytest
|
| 43 |
+
|
| 44 |
+
pytest.importorskip("openra_train", reason="Rust env wheel not installed")
|
| 45 |
+
pytest.importorskip(
|
| 46 |
+
"openra_rl_training", reason="Rust env wheel not installed"
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
from openra_bench.eval_core import run_level
|
| 50 |
+
from openra_bench.scenarios import load_pack
|
| 51 |
+
from openra_bench.scenarios.loader import PACKS_DIR, compile_level
|
| 52 |
+
|
| 53 |
+
PACK = PACKS_DIR / "def-pre-position-mobile-reserve.yaml"
|
| 54 |
+
LEVELS = ("easy", "medium", "hard")
|
| 55 |
+
SEEDS = (1, 2, 3, 4)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
# ── scripted policies ────────────────────────────────────────────────
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def stall(rs, C):
|
| 62 |
+
"""Observe-only. The stance:3 reserve auto-engages the rush when
|
| 63 |
+
it reaches the centre, racking up kills via the engine, but the
|
| 64 |
+
tanks NEVER MOVE OUT of the starting cluster → forward-zone
|
| 65 |
+
clauses never satisfied → LOSS."""
|
| 66 |
+
return [C.observe()]
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def commit_north(rs, C):
|
| 70 |
+
"""Move the WHOLE reserve to the NORTH intercept zone on turn 1.
|
| 71 |
+
On easy (rush IS from NORTH) this WINS. On medium/hard the S
|
| 72 |
+
(and E) forward zones stay empty → LOSS on the position
|
| 73 |
+
clause(s)."""
|
| 74 |
+
units = [
|
| 75 |
+
u for u in rs.get("units_summary", []) if u.get("type") == "2tnk"
|
| 76 |
+
]
|
| 77 |
+
if not units:
|
| 78 |
+
return [C.observe()]
|
| 79 |
+
ids = [str(u["id"]) for u in units]
|
| 80 |
+
return [C.attack_move(ids, target_x=60, target_y=12)]
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def commit_south(rs, C):
|
| 84 |
+
"""Move the WHOLE reserve to the SOUTH intercept zone on turn 1.
|
| 85 |
+
On every level S is either wrong (easy: rush is NORTH) or
|
| 86 |
+
insufficient (medium/hard: other zones empty) → LOSS."""
|
| 87 |
+
units = [
|
| 88 |
+
u for u in rs.get("units_summary", []) if u.get("type") == "2tnk"
|
| 89 |
+
]
|
| 90 |
+
if not units:
|
| 91 |
+
return [C.observe()]
|
| 92 |
+
ids = [str(u["id"]) for u in units]
|
| 93 |
+
return [C.attack_move(ids, target_x=60, target_y=28)]
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def make_intended():
|
| 97 |
+
"""Stable per-tank assignment so each tank's destination doesn't
|
| 98 |
+
flip frame-to-frame (re-pathing scrambles the split). On the
|
| 99 |
+
FIRST call, sort tank ids and read enemy positions to detect
|
| 100 |
+
which lanes are active; assign tanks to the active lanes
|
| 101 |
+
(NORTH-only on easy, NORTH+SOUTH on medium, NORTH+CENTRE+SOUTH
|
| 102 |
+
on hard)."""
|
| 103 |
+
|
| 104 |
+
state = {"assignments": None, "level": None}
|
| 105 |
+
|
| 106 |
+
def policy(rs, C):
|
| 107 |
+
own = [
|
| 108 |
+
u for u in rs.get("units_summary", [])
|
| 109 |
+
if u.get("type") == "2tnk"
|
| 110 |
+
]
|
| 111 |
+
if not own:
|
| 112 |
+
return [C.observe()]
|
| 113 |
+
ids = sorted(str(u["id"]) for u in own)
|
| 114 |
+
if state["assignments"] is None:
|
| 115 |
+
# Wait until enemies are visible (interrupt mode fires
|
| 116 |
+
# enemy_unit_spotted quickly), then detect active lanes.
|
| 117 |
+
enem = [
|
| 118 |
+
e for e in (rs.get("enemy_summary") or [])
|
| 119 |
+
if e.get("type") != "fact"
|
| 120 |
+
]
|
| 121 |
+
if not enem:
|
| 122 |
+
# Enemies not yet visible — hold at centre (observe)
|
| 123 |
+
# until interrupt fires.
|
| 124 |
+
return [C.observe()]
|
| 125 |
+
n_band = any(e["cell_y"] < 18 for e in enem)
|
| 126 |
+
s_band = any(e["cell_y"] > 22 for e in enem)
|
| 127 |
+
e_band = any(
|
| 128 |
+
18 <= e["cell_y"] <= 22 and e["cell_x"] > 60
|
| 129 |
+
for e in enem
|
| 130 |
+
)
|
| 131 |
+
active = []
|
| 132 |
+
if n_band:
|
| 133 |
+
active.append("N")
|
| 134 |
+
if e_band:
|
| 135 |
+
active.append("C")
|
| 136 |
+
if s_band:
|
| 137 |
+
active.append("S")
|
| 138 |
+
if not active:
|
| 139 |
+
return [C.observe()]
|
| 140 |
+
n = len(ids)
|
| 141 |
+
if len(active) == 1:
|
| 142 |
+
state["assignments"] = {active[0]: ids}
|
| 143 |
+
elif len(active) == 2:
|
| 144 |
+
half = max(1, n // 2)
|
| 145 |
+
state["assignments"] = {
|
| 146 |
+
active[0]: ids[:half], active[1]: ids[half:]
|
| 147 |
+
}
|
| 148 |
+
elif len(active) == 3:
|
| 149 |
+
third = max(1, n // 3)
|
| 150 |
+
state["assignments"] = {
|
| 151 |
+
active[0]: ids[:third],
|
| 152 |
+
active[1]: ids[third:2 * third],
|
| 153 |
+
active[2]: ids[2 * third:],
|
| 154 |
+
}
|
| 155 |
+
a = state["assignments"]
|
| 156 |
+
alive = set(ids)
|
| 157 |
+
cmds = []
|
| 158 |
+
if "N" in a:
|
| 159 |
+
nids = [i for i in a["N"] if i in alive]
|
| 160 |
+
if nids:
|
| 161 |
+
cmds.append(
|
| 162 |
+
C.attack_move(nids, target_x=60, target_y=12)
|
| 163 |
+
)
|
| 164 |
+
if "C" in a:
|
| 165 |
+
cids = [i for i in a["C"] if i in alive]
|
| 166 |
+
if cids:
|
| 167 |
+
cmds.append(
|
| 168 |
+
C.attack_move(cids, target_x=65, target_y=20)
|
| 169 |
+
)
|
| 170 |
+
if "S" in a:
|
| 171 |
+
sids = [i for i in a["S"] if i in alive]
|
| 172 |
+
if sids:
|
| 173 |
+
cmds.append(
|
| 174 |
+
C.attack_move(sids, target_x=60, target_y=28)
|
| 175 |
+
)
|
| 176 |
+
return cmds or [C.observe()]
|
| 177 |
+
|
| 178 |
+
return policy
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
# ── structural checks (no engine) ────────────────────────────────────
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
def test_pack_loads_and_metadata_is_complete():
|
| 185 |
+
pack = load_pack(PACK)
|
| 186 |
+
assert pack.meta.id == "def-pre-position-mobile-reserve"
|
| 187 |
+
assert pack.meta.capability == "reasoning"
|
| 188 |
+
anchors = pack.meta.benchmark_anchor or []
|
| 189 |
+
assert anchors, "benchmark_anchor must be non-empty"
|
| 190 |
+
assert any("reserve" in a.lower() for a in anchors), anchors
|
| 191 |
+
assert any(
|
| 192 |
+
"chess" in a.lower() or "central" in a.lower() for a in anchors
|
| 193 |
+
), anchors
|
| 194 |
+
# Rusher bot wired through to the engine for every level.
|
| 195 |
+
for lvl in LEVELS:
|
| 196 |
+
c = compile_level(pack, lvl)
|
| 197 |
+
assert c.map_supported
|
| 198 |
+
enemy = c.scenario.enemy
|
| 199 |
+
bot = getattr(enemy, "bot_type", None) or getattr(enemy, "bot", None)
|
| 200 |
+
assert str(bot).lower() == "rusher", (lvl, bot)
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
@pytest.mark.parametrize("level", LEVELS)
|
| 204 |
+
def test_every_level_has_a_reachable_timeout_fail(level):
|
| 205 |
+
"""Non-win must be a real LOSS: the `after_ticks` fail must be
|
| 206 |
+
strictly below the tick reachable at max_turns (≤90 ticks/step
|
| 207 |
+
in interrupt mode)."""
|
| 208 |
+
c = compile_level(load_pack(PACK), level)
|
| 209 |
+
assert c.fail_condition is not None
|
| 210 |
+
fc = c.fail_condition.model_dump(exclude_none=True)
|
| 211 |
+
deadline = None
|
| 212 |
+
for clause in fc.get("any_of", []) or []:
|
| 213 |
+
if "after_ticks" in clause:
|
| 214 |
+
deadline = int(clause["after_ticks"])
|
| 215 |
+
assert deadline is not None, f"{level}: no after_ticks fail clause"
|
| 216 |
+
reachable = 93 + 90 * (c.max_turns - 1)
|
| 217 |
+
assert deadline < reachable, (
|
| 218 |
+
f"{level}: deadline {deadline} unreachable within "
|
| 219 |
+
f"{c.max_turns} turns (max tick {reachable}) → draw degeneracy"
|
| 220 |
+
)
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
@pytest.mark.parametrize("level", LEVELS)
|
| 224 |
+
def test_every_level_enforces_forward_zone(level):
|
| 225 |
+
"""The position axis must be load-bearing: every level's win
|
| 226 |
+
condition must require at least one `units_in_region_gte` clause
|
| 227 |
+
(the forward-zone discriminator). Medium and hard require ≥2
|
| 228 |
+
zones (must split)."""
|
| 229 |
+
c = compile_level(load_pack(PACK), level)
|
| 230 |
+
win = c.win_condition.model_dump(exclude_none=True)
|
| 231 |
+
flat = str(win)
|
| 232 |
+
assert "units_in_region_gte" in flat, win
|
| 233 |
+
# Count zones (one per occurrence in the win dict).
|
| 234 |
+
zone_count = flat.count("units_in_region_gte")
|
| 235 |
+
if level == "easy":
|
| 236 |
+
assert zone_count >= 1, (level, zone_count, win)
|
| 237 |
+
elif level == "medium":
|
| 238 |
+
assert zone_count >= 2, (level, zone_count, win)
|
| 239 |
+
elif level == "hard":
|
| 240 |
+
assert zone_count >= 3, (level, zone_count, win)
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
def test_hard_has_two_spawn_point_groups():
|
| 244 |
+
"""Hard-tier contract: ≥2 distinct seed-driven spawn_point groups
|
| 245 |
+
so the reserve's starting cell rotates by seed (anti-memorisation
|
| 246 |
+
of an absolute cell — the doctrine must generalise)."""
|
| 247 |
+
c = compile_level(load_pack(PACK), "hard")
|
| 248 |
+
groups = {
|
| 249 |
+
a.spawn_point for a in c.scenario.actors
|
| 250 |
+
if a.owner == "agent" and a.spawn_point is not None
|
| 251 |
+
}
|
| 252 |
+
assert groups == {0, 1}, groups
|
| 253 |
+
# In-bounds check (rush-hour-arena playable y ≈ 2..38).
|
| 254 |
+
for a in c.scenario.actors:
|
| 255 |
+
x, y = a.position
|
| 256 |
+
assert 2 <= x <= 126 and 2 <= y <= 38, (a.type, a.position)
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
# ── solvency: intended WINS every level + every hard seed ────────────
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
@pytest.mark.parametrize("level", LEVELS)
|
| 263 |
+
def test_intended_split_intercept_wins_every_level_and_seed(level):
|
| 264 |
+
c = compile_level(load_pack(PACK), level)
|
| 265 |
+
for seed in SEEDS:
|
| 266 |
+
r = run_level(c, make_intended(), seed=seed)
|
| 267 |
+
assert r.outcome == "win", (
|
| 268 |
+
f"{level} seed{seed}: intended split/forward-intercept play "
|
| 269 |
+
f"must WIN; got {r.outcome} "
|
| 270 |
+
f"(tick={r.signals.game_tick}, "
|
| 271 |
+
f"kills={r.signals.units_killed}, "
|
| 272 |
+
f"lost={r.signals.units_lost})"
|
| 273 |
+
)
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
# ── no-cheat: every wrong / lazy policy LOSES (real LOSS, not draw) ──
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
@pytest.mark.parametrize("level", LEVELS)
|
| 280 |
+
def test_stall_loses_every_level_and_seed(level):
|
| 281 |
+
"""Stall (observe only) — the reserve never reaches the forward
|
| 282 |
+
zone(s) → LOSS even when the auto-defence racks up kills."""
|
| 283 |
+
c = compile_level(load_pack(PACK), level)
|
| 284 |
+
for seed in SEEDS:
|
| 285 |
+
r = run_level(c, stall, seed=seed)
|
| 286 |
+
assert r.outcome == "loss", (
|
| 287 |
+
f"{level} seed{seed} stall: must LOSE (real fail, not draw); "
|
| 288 |
+
f"got {r.outcome} (tick={r.signals.game_tick}, "
|
| 289 |
+
f"kills={r.signals.units_killed}, "
|
| 290 |
+
f"lost={r.signals.units_lost})"
|
| 291 |
+
)
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
@pytest.mark.parametrize("level", ("medium", "hard"))
|
| 295 |
+
def test_commit_north_loses_on_multi_flank_levels(level):
|
| 296 |
+
"""Committing the WHOLE reserve to NORTH leaves the SOUTH (and on
|
| 297 |
+
hard, also the CENTRE/E) forward zone(s) empty → position-clause
|
| 298 |
+
LOSS. (On EASY commit-NORTH is the intended single-direction
|
| 299 |
+
play and WINS — that case is covered by the intended-WIN test.)"""
|
| 300 |
+
c = compile_level(load_pack(PACK), level)
|
| 301 |
+
for seed in SEEDS:
|
| 302 |
+
r = run_level(c, commit_north, seed=seed)
|
| 303 |
+
assert r.outcome == "loss", (
|
| 304 |
+
f"{level} seed{seed} commit-NORTH: must LOSE on multi-flank "
|
| 305 |
+
f"level; got {r.outcome} (tick={r.signals.game_tick}, "
|
| 306 |
+
f"kills={r.signals.units_killed}, "
|
| 307 |
+
f"lost={r.signals.units_lost})"
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
@pytest.mark.parametrize("level", LEVELS)
|
| 312 |
+
def test_commit_south_loses_every_level_and_seed(level):
|
| 313 |
+
"""Committing the WHOLE reserve to SOUTH is always wrong — on
|
| 314 |
+
easy the rush is NORTH (S zone irrelevant); on medium/hard the
|
| 315 |
+
N (and E) forward zones stay empty → LOSS."""
|
| 316 |
+
c = compile_level(load_pack(PACK), level)
|
| 317 |
+
for seed in SEEDS:
|
| 318 |
+
r = run_level(c, commit_south, seed=seed)
|
| 319 |
+
assert r.outcome == "loss", (
|
| 320 |
+
f"{level} seed{seed} commit-SOUTH: must LOSE; got "
|
| 321 |
+
f"{r.outcome} (tick={r.signals.game_tick}, "
|
| 322 |
+
f"kills={r.signals.units_killed}, "
|
| 323 |
+
f"lost={r.signals.units_lost})"
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
# ── determinism ──────────────────────────────────────────────────────
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
def test_intended_run_is_deterministic_on_easy():
|
| 331 |
+
c = compile_level(load_pack(PACK), "easy")
|
| 332 |
+
a = run_level(c, make_intended(), seed=2)
|
| 333 |
+
b = run_level(c, make_intended(), seed=2)
|
| 334 |
+
assert (a.outcome, a.turns) == (b.outcome, b.turns), (
|
| 335 |
+
"same seed must be deterministic"
|
| 336 |
+
)
|