code wiki / (root) / nx_decl_random_environment.nx

nx_decl_random_environment.nx

buildroot/runtime/nx_decl_random_environment.nx

7280 B180 linesdepth 3pulls 4 transitivereach 10 importersview sourcekind librarytopic decl
docsdependenciesstructsconstsfunctions

about

nx_decl_random_environment.nx -- declarative environment generator. license_tier: ORIGINAL First substrate primitive in the "#tag" ergonomic family: one substrate call produces a fully-specified procedural environment from a single MODIFIER + SEED. Equivalent of TypeScript `#random_environment real` -- the substrate fills in everything (size, biome, river count, forest count, settlement, decoration density) with sensible defaults seeded by the modifier. Mission cardinal: declarative > imperative for scene authoring. Game authors write one line, substrate composes from nx_biome_classifier + nx_forest_layout + nx_river_carve + sealed enums. Per the user's S-class roadmap directive 2026-05-16. Usage: let env: NxRandomEnvironment nx_decl_random_environment(&env, NX_RE_MODIFIER_REAL, 0xC0FFEE) // env is now fully populated.

dependencies 4 imports · 10 importers

nx_syscalls.nx nx_types.nx nx_tier.nx nx_biome_classifier.nx nx_decl_random_environment.nx nx_decl_combat_arena.nx nx_decl_combat_arena_test.nx nx_decl_dungeon_floor.nx nx_decl_dungeon_floor_test.nx nx_decl_random_environment_test.nx nx_decl_reflection_test.nx nx_decl_simple_scene.nx nx_decl_simple_scene_test.nx nx_decl_townscape.nx nx_decl_townscape_test.nx

imports: nx_syscalls.nxnx_types.nxnx_tier.nxnx_biome_classifier.nx

imported by: nx_decl_combat_arena.nxnx_decl_combat_arena_test.nxnx_decl_dungeon_floor.nxnx_decl_dungeon_floor_test.nxnx_decl_random_environment_test.nxnx_decl_reflection_test.nxnx_decl_simple_scene.nxnx_decl_simple_scene_test.nxnx_decl_townscape.nxnx_decl_townscape_test.nx

structs

57struct NxRandomEnvironment

consts

35const NX_RE_MODIFIER_REAL: nx_int = 0 // Earth-like physics + biomes
36const NX_RE_MODIFIER_FANTASY: nx_int = 1 // exaggerated scale, magic biomes
37const NX_RE_MODIFIER_SCI_FI: nx_int = 2 // alien biomes, large scale
38const NX_RE_MODIFIER_N: nx_int = 3

functions

40func nx_re_modifier_is_valid(m: nx_int) -> nx_int
49func nx_re_modifier_name(m: nx_int) -> *u8
called by 3: mainmainmain
73func _re_hash_mod(seed: nx_int, salt: nx_int, modulus: nx_int) -> nx_int
82func _re_default_size(modifier: nx_int) -> nx_int
89func _re_default_river_count(modifier: nx_int, biome: nx_int) -> nx_int
102func _re_default_forest_count(modifier: nx_int, biome: nx_int) -> nx_int
117func _re_default_decoration_density(modifier: nx_int, biome: nx_int) -> nx_int
128func _re_default_elevation_max(modifier: nx_int, biome: nx_int) -> nx_int
142func nx_decl_random_environment(out: *NxRandomEnvironment, modifier: nx_int, seed: nx_int) -> nx_int
176func nx_re_alloc() -> *NxRandomEnvironment
called by 2: mainnx_decl_simple_scene calls 1: sys_mmap