code wiki / _hdl_build / nx_procgen.nx
nx_procgen.nx
buildroot/runtime/_hdl_build/nx_procgen.nx
about
nx_procgen.nx -- procedural DUNGEON/maze generation, pure-Nishi NO-FLOAT (seeded integer LCG, iterative DFS).
Closes the RESEARCHED->PRESENT gap the research census (GR-S-R5) named for P5 (procedural-generation src=13,
the highest-evidence unbuilt cell). Randomized-DFS "recursive backtracker" carves a PERFECT maze on a grid
(0=open 1=wall): fully connected by construction, exactly one path between any two open cells. Deterministic
(same seed -> same maze). Reusable: roguelike/dungeon levels, RTS maps, tower-defense paths. Composes with
nx_pathfind (A*) -- procgen generates, pathfinding verifies reachability. license_tier: ORIGINAL
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_m2d_engine.nxnx_procgen_gate.nx
structs
| none |
consts
| 8 | const K_MAGIC_1103515245: i64 = 1103515245 |
| 9 | const K_MAGIC_12345: i64 = 12345 |
functions
| 11 | func pg_rng(seed: *i64) -> i64 { seed[0] = (seed[0]*K_MAGIC_1103515245 + K_MAGIC_12345) & 0x7fffffff; return seed[0] } called by 1: pg_maze |
| 15 | func pg_maze(grid: *i64, w: i64, h: i64, seedv: i64, stack: *i64) -> i64 |
| 45 | func pg_count_open(grid: *i64, n: i64) -> i64 { var c: i64=0; var i: i64=0; while i<n { if grid[i]==0 { c=c+1 } i=i+1 } return c } called by 1: main |
| 48 | func pg_flood_count(grid: *i64, w: i64, h: i64, sx: i64, sy: i64, visited: *i64, queue: *i64) -> i64 called by 1: main |