code wiki / _hdl_build / nx_maze_gen.nx

nx_maze_gen.nx

buildroot/runtime/_hdl_build/nx_maze_gen.nx

6544 B120 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_maze_gen.nx -- LIB: three foundational rungs toward AUTONOMOUS S-class game emission, in pure-integer Nishi (no float, no third-party): procgen-solvable : mz_gen builds a maze by integer DFS recursive-backtracker -> a SPANNING TREE, so EVERY cell is reachable BY CONSTRUCTION (an emitted level can never be unsolvable). gate-solvable : mz_solve is a BFS solver that PROVES a start->exit path exists (returns its length) or reports UNSOLVABLE (-1). The validation gate that makes "automatically emit a game" SAFE: no emitted level ships unless the solver confirms it is winnable. rules-engine : the maze is a grid with rules-as-data (wall bits per cell) + movement rules + win=reach-exit. mz_seal isolates a cell (the gate's negative control: a deliberately-broken level the solver MUST catch). Deterministic (LCG seed) -> reproducible emission. Cell = 4 wall bits N=1 E=2 S=4 W=8 (bit4=16 visited, scratch). license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_maze_gen.nx nx_maze_gate.nx

imports: nx_syscalls.nx

imported by: nx_maze_gate.nx

structs

none

consts

13const K_MAGIC_1103515245: i64 = 1103515245
14const K_MAGIC_12345: i64 = 12345
15const K_MAGIC_32767: i64 = 32767

functions

17func mz_rng(seedbox: *i64) -> i64 { var x: i64 = seedbox[0]; x = x * K_MAGIC_1103515245 + K_MAGIC_12345; seedbox[0] = x; return (x >> 16) & K_MAGIC_32767 }
called by 1: mz_gen
20func mz_gen(seed: i64, w: i64, h: i64, cells: *u8) -> i64
called by 1: main calls 2: sys_mmapmz_rng
54func mz_solve(cells: *u8, w: i64, h: i64, start: i64, exit_c: i64, dist: *i64, queue: *i64) -> i64
called by 1: main
71func mz_reachable(dist: *i64, n: i64) -> i64 { var c: i64 = 0; var i: i64 = 0; while i < n { if dist[i] != (0 - 1) { c = c + 1 } i = i + 1 } return c }
called by 1: main
74func mz_seal(cells: *u8, w: i64, h: i64, c: i64) -> i64
called by 1: main
85func mz_ascii(cells: *u8, w: i64, h: i64, start: i64, exit_c: i64, buf: *u8) -> i64
called by 1: main