summaryrefslogtreecommitdiff
path: root/1mb/data.js
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-07-13 00:26:52 -0500
committerChristian Cleberg <[email protected]>2026-07-13 18:46:35 -0500
commitf1a0321e1edb598cd1eb421e4621be769b2d8b75 (patch)
treec5d1307a4db81aa56acbce273cf117a05689e492 /1mb/data.js
parentde2460845efda51820eb3c6343fb158661ae76bb (diff)
downloadmicro-roguelike-f1a0321e1edb598cd1eb421e4621be769b2d8b75.tar.gz
micro-roguelike-f1a0321e1edb598cd1eb421e4621be769b2d8b75.tar.bz2
micro-roguelike-f1a0321e1edb598cd1eb421e4621be769b2d8b75.zip
Phase 0–1: verification guardrails and engine enablers for the 1MB expansion (#2)
* Add byte-budget gate, headless solver harness, and size ledger Phase 0 guardrails for the 1MB roguelike; no changes under 1mb/. - tools/check-size.sh: per-file byte ledger for 1mb/, fails past 1 MiB, warns loudly past 95% - tools/validate.js: evaluates the unmodified game in a stubbed vm environment and sweeps seeds x floors 2-6 through the real escapeSolve, failing on any unwinnable escape room - tools/check.sh: single entry point running both gates - tools/pre-commit: optional installable hook running check.sh - README: Budget & verification section; docs/SIZES.md: ledger seeded at 82,240 B (7.8% of budget) * Task 1.1: data-driven floor graph Move room topology out of build() into a GRAPH table in data.js: each floor declares its room set and exit wiring (TOPO shared by floors 1-7), and build() consumes it generically. BASES flatten to raw map arrays since their exit wiring now lives in GRAPH. Two new graph capabilities, exercised by a hidden floor-9 proving ground (debug key T): extra room instances beyond the nine fixed codes (h2, inheriting family behavior from its first letter — spawn, darkness, room text, path counters) and one-way exits ("!dest" seals after one crossing). Guard cover()/the debug solve line for floors with no e room. Behavior-neutral: fixed-seed summary() and variantSummary() identical across floors 1-7 before/after; save format unchanged (v:1 round-trips). * Task 1.2: procedural room generator Add genRoom(rand, spec) to the engine: builds a 12x12 map from a spec (required exit letters, pit-room O ring, wall-cluster and pit-vein tile budgets, trap/item sprinkles, a stamp pattern for the idol ring) with perimeter walls and a flood-fill guarantee that every walkable tile and exit stays mutually reachable — block-overlay spots count as solid, and overlay spot coords plus spawns are forced open so hazards never bury a door. Bounded retries end in a sparse layout, then an authored fallback. Floors 2+ draw each variant pick from the authored arrays plus PROC_SLOTS=2 generated slots per room type (PROC_SPECS in data.js); escapes stay authored from floor 6 up and BASES rooms are never generated. Procedural escape rooms are gated by escapeSolve at build time with regeneration on failure. Fully deterministic per seed. Generator weighs 3,268 bytes. validate.js 500: 2500/2500 solvable. * Task 1.3: full-floor solver Add floorSolve(seed, level) to the engine: proves a floor completable end to end — gate to bones for the torch, hall to idol for the bow, hall to vault via pit or crack, crown and key pickups, then the escape room via the existing beast simulation, back to the gate. Room legs are BFS path costs over the built maps with block overlays solid and pits never crossed; exits and item tiles are located dynamically from the GRAPH-built rooms, so future topologies validate without changes. Floor 1 crosses the escape room at torch 8 (fresh-run fuel plus an allowed brazier refuel; 6 was falsely failing a third of floor-1 seeds that play fine). validateSeeds (V key) and tools/validate.js now sweep floors 1-7 with full-floor checks: 200 seeds x 7 floors in ~6.5s, 500 in ~15s. The debug panel gains a "floor : ok:<cost>" line (n/a on graphs without idol/vault/escape rooms). A scratch copy with the vault crown walled off fails 250/350 checks with per-floor variant detail.
Diffstat (limited to '1mb/data.js')
-rw-r--r--1mb/data.js87
1 files changed, 64 insertions, 23 deletions
diff --git a/1mb/data.js b/1mb/data.js
index 1a9e32f..2fdae59 100644
--- a/1mb/data.js
+++ b/1mb/data.js
@@ -944,7 +944,7 @@ const ESCAPES6=[[
"############"]]
const BEASTS6=[[10,8],[10,7],[9,7],[10,6]]
const LEVEL_ORDER=[1,2,3,4,5,6]
-const LEVEL_ARCS={1:"foundation",2:"pressure",3:"ward",4:"hunt",5:"hollow",6:"finale",7:"afterglow"}
+const LEVEL_ARCS={1:"foundation",2:"pressure",3:"ward",4:"hunt",5:"hollow",6:"finale",7:"afterglow",9:"proving ground"}
const MODES={
standard:{label:"standard",desc:"full campaign"},
iron:{label:"iron",desc:"early beast"},
@@ -980,7 +980,8 @@ const FLOOR_THEMES={
4:{name:"hunt",tag:"rose alarm",accent:"pink hunt",fog:"thin red haze"},
5:{name:"hollow",tag:"ash hush",accent:"bone gray",fog:"dry blackout"},
6:{name:"finale",tag:"crown weather",accent:"gold ruin",fog:"judging dark"},
- 7:{name:"afterglow",tag:"borrowed dawn",accent:"ash gold",fog:"embered haze"}
+ 7:{name:"afterglow",tag:"borrowed dawn",accent:"ash gold",fog:"embered haze"},
+ 9:{name:"proving ground",tag:"debug",accent:"bare stone",fog:"none"}
}
const ENEMY_TEXT={
beast:["A one-eyed pursuer that reads space better than fear.","It wants a lane, not a duel."],
@@ -1124,10 +1125,11 @@ const LEVELS={
4:{pits:PITS4,idols:IDOLS4,cracks:CRACKS4,halls:HALLS4,escapes:ESCAPES4,beasts:BEASTS4,dark:"behipcv",tone:"The hunt floor listens for every sound you make."},
5:{pits:PITS4,idols:IDOLS4,cracks:CRACKS4,halls:HALLS4,escapes:ESCAPES5,beasts:BEASTS5,dark:"behipcv",tone:"The hollow floor strips away whatever was merely enough."},
6:{pits:PITS4,idols:IDOLS4,cracks:CRACKS4,halls:HALLS4,escapes:ESCAPES6,beasts:BEASTS6,dark:"behipcv",tone:"The final gate wakes. Everything left in you will be tested."},
-7:{pits:PITS4,idols:IDOLS4,cracks:CRACKS4,halls:HALLS4,escapes:ESCAPES6,beasts:BEASTS6,dark:"behipcv",tone:"You already won. The ruin didn't agree to let you leave."}
+7:{pits:PITS4,idols:IDOLS4,cracks:CRACKS4,halls:HALLS4,escapes:ESCAPES6,beasts:BEASTS6,dark:"behipcv",tone:"You already won. The ruin didn't agree to let you leave."},
+9:{pits:PITS,idols:IDOLS,cracks:CRACKS,halls:HALLS,escapes:ESCAPES,beasts:BEASTS,dark:"",tone:"A proving ground outside the campaign."}
}
const BASE={
-g:{m:[
+g:[
"############",
"#..........#",
"#..L.....R.#",
@@ -1139,8 +1141,8 @@ g:{m:[
"#..........#",
"#..........#",
"#..........#",
-"############"],ex:{">":"h",L:"b",R:"e"}},
-b:{m:[
+"############"],
+b:[
"############",
"#..........#",
"#...MT.....#",
@@ -1152,8 +1154,8 @@ b:{m:[
"#..........#",
"#..........#",
"#..........#",
-"############"],ex:{">":"h"}},
-v:{m:[
+"############"],
+v:[
"############",
"#..........#",
"#....C.K...#",
@@ -1165,11 +1167,11 @@ v:{m:[
"#..........#",
"#....>.....#",
"#..........#",
-"############"],ex:{">":"e"}},
-d:{m:["############","#..........#","#..........#","#..........#","#....X.....#","#..........#","#..........#","#..........#","#..........#","#..........#","#..........#","############"],ex:{}}
+"############"],
+d:["############","#..........#","#..........#","#..........#","#....X.....#","#..........#","#..........#","#..........#","#..........#","#..........#","#..........#","############"]
}
const BASE2={
-g:{m:[
+g:[
"############",
"#..........#",
"#..L..#..R.#",
@@ -1181,8 +1183,8 @@ g:{m:[
"#..........#",
"#..........#",
"#..........#",
-"############"],ex:{">":"h",L:"b",R:"e"}},
-b:{m:[
+"############"],
+b:[
"############",
"#..........#",
"#...MT.....#",
@@ -1194,8 +1196,8 @@ b:{m:[
"#..........#",
"#..........#",
"#..........#",
-"############"],ex:{">":"h"}},
-v:{m:[
+"############"],
+v:[
"############",
"#..........#",
"#...#C.K...#",
@@ -1207,11 +1209,11 @@ v:{m:[
"#..........#",
"#...>......#",
"#..........#",
-"############"],ex:{">":"e"}},
+"############"],
d:BASE.d
}
const BASE3={
-g:{m:[
+g:[
"############",
"#..........#",
"#..L..S..R.#",
@@ -1223,8 +1225,8 @@ g:{m:[
"#..........#",
"#..........#",
"#..........#",
-"############"],ex:{">":"h",L:"b",R:"e"}},
-b:{m:[
+"############"],
+b:[
"############",
"#..........#",
"#..SMT.....#",
@@ -1236,8 +1238,8 @@ b:{m:[
"#..........#",
"#..........#",
"#..........#",
-"############"],ex:{">":"h"}},
-v:{m:[
+"############"],
+v:[
"############",
"#..........#",
"#...#C.K.S.#",
@@ -1249,7 +1251,46 @@ v:{m:[
"#..........#",
"#...>......#",
"#..........#",
-"############"],ex:{">":"e"}},
+"############"],
d:BASE.d
}
-const BASES={1:BASE,2:BASE2,3:BASE3,4:BASE3,5:BASE3,6:BASE3,7:BASE3}
+const BASES={1:BASE,2:BASE2,3:BASE3,4:BASE3,5:BASE3,6:BASE3,7:BASE3,9:BASE}
+// Procedural room slots: floors 2+ draw each variant pick from the authored
+// arrays above plus PROC_SLOTS generated layouts per room type (escapes only
+// through floor 5 — the finale arenas stay authored, as do BASES rooms).
+// Specs feed genRoom() in the engine: exits lists required exit letters
+// ("any" = random open tile), ring is the pit-room O border, walls and pits
+// are tile budgets for wall clusters and pit veins, traps/items sprinkle
+// chars onto open floor, stamp drops a small pattern whole onto the map.
+const PROC_SLOTS=2
+const PROC_SPECS={
+ pits:{ring:1,pits:9,walls:2,exits:{">":"any"},items:{F:1}},
+ idols:{walls:3,exits:{">":"any"},stamp:["ggg","gIg","ggg"]},
+ cracks:{walls:14,traps:{x:3},exits:{">":"any"}},
+ halls:{walls:5,exits:{a:"any",b:"any",c:"any",d:"any",">":"any"},items:{F:1}},
+ escapes:{walls:5,exits:{">":"any"}}
+}
+// Floor topology: room set + exit wiring, consumed generically by build().
+// base: fixed map from BASES[floor]. arr + v: variant array in LEVELS[floor]
+// and the V slot that picks the variant. An exit destination prefixed "!" is
+// one-way: it seals behind you after one crossing. Room codes beyond one char
+// (h2) are extra instances; they inherit family behavior from the first letter.
+const TOPO={
+ g:{base:"g",ex:{">":"h",L:"b",R:"e"}},
+ b:{base:"b",ex:{">":"h"}},
+ v:{base:"v",ex:{">":"e"}},
+ d:{base:"d",ex:{}},
+ h:{arr:"halls",v:"hall",ex:{a:"p",b:"i",c:"c",d:"d",">":"g"}},
+ p:{arr:"pits",v:"pit",ex:{">":"v"}},
+ i:{arr:"idols",v:"idol",ex:{">":"h"}},
+ c:{arr:"cracks",v:"crack",ex:{">":"v"}},
+ e:{arr:"escapes",v:"escape",ex:{">":"g"}}
+}
+const GRAPH={1:TOPO,2:TOPO,3:TOPO,4:TOPO,5:TOPO,6:TOPO,7:TOPO,
+// floor 9: debug proving ground (T in play) — a second hall instance reached
+// by a one-way drop; exit b in h2 climbs back to the first hall.
+9:{
+ g:{base:"g",ex:{">":"h"}},
+ h:{arr:"halls",v:"hall",ex:{a:"!h2",">":"g"}},
+ h2:{arr:"halls",v:"hall",ex:{b:"h",">":"g"}}
+}}