code wiki / (root) / nx_world_quality_grader.nx

nx_world_quality_grader.nx

buildroot/runtime/nx_world_quality_grader.nx

36490 B905 linesdepth 2pulls 2 transitivereach 10 importersview sourcekind tooltopic world
docsdependenciesstructsconstsfunctions

about

nx_world_quality_grader.nx -- mathematical verdict for procgen worlds. Per user 2026-05-16: "build an iterative loop like we got going on elder ai i dont want to have to manually check if you generate good maps. does minecraft or these other prc gens have something that actually mathematically measures if the world is good like how god says and i saw it was good as a confirmation check its not trash" Genesis 1:31 -- "And God saw every thing that he had made, and, behold, it was very good." This primitive ships the substrate's SABBATH GRADER for generated worlds: a per-tick verdict over a heightmap that returns sealed-enum grade + per-axis Q14 scores + refine-axis directive so the caller can iterate. Most procgens (Minecraft, Houdini, No Man's Sky, Spelunky) have NO mathematical world-quality measurement -- generation is one-shot noise with hand-tuned constants. The substrate's posture is honest-perf-verdict: every output has a measurable verdict, and every LOSE carries a named_improvement. This primitive surfaces that posture at the WORLD level. FULL CAPABILITY (per feedback-maximum-capability-no-simplification cardinal, 2026-05-16): 8 axes: DIVERSITY -- (max-min) / max_possible_relief. Range-based. LOCAL_VARIATION -- mean |neighbour-difference| / max_relief. Banded (too jagged is also bad). EXTREMES -- ratio of cells in top-10% + bottom-10%. Signature features push this up. FLATNESS_PENALTY -- ratio of cells at modal-bucket height. HIGHER = MORE FLAT = WORSE; verdict inverts. FRACTAL_DIM -- Hurst-exponent estimator via multi-scale mean-abs-diff slope. Spehar 2003: most aesthetically pleasing fractal dimension band maps to H in [0.3, 0.7]. Peak band 0.4-0.6. BIOME_COHERENCE -- fraction of cells where biome ID matches expected elevation band (DESERT at low, FOREST at mid, SNOW at high). Caller-supplied biome_map. Skipped (verdict=MARGINAL) if NULL.

dependencies 2 imports · 6 importers

nx_syscalls.nx nx_tier.nx nx_world_quality_grader.nx _ft_diag.nx nx_procgen_biome_test.nx nx_procgen_features_test.nx nx_procgen_signature_test.nx nx_procgen_water_test.nx nx_worldgen_tunelib.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: _ft_diag.nxnx_procgen_biome_test.nxnx_procgen_features_test.nxnx_procgen_signature_test.nxnx_procgen_water_test.nxnx_worldgen_tunelib.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap nx_grade_is_valid nx_wqg_refine_is_valid nx_world_quality_grade sys_mmap ↻ _wqg_fractal_dim_score _wqg_biome_coherence_score _wqg_biome_expected_band _wqg_feature_variety_score _wqg_log2_q14_table _wqg_readability_score _wqg_axis_verdict _wqg_axis_verdict_banded _wqg_grade_from_8 _wqg_pick_refine_axis _wqg_grade_from_8 ↻

structs

none

consts

84const NX_MAGIC_23170: i64 = 23170
85const NX_MAGIC_4096: i64 = 4096
86const NX_MAGIC_8192: i64 = 8192
87const NX_MAGIC_46341: i64 = 46341
88const NX_MAGIC_12288: i64 = 12288
89const NX_MAGIC_16384: i64 = 16384
90const NX_MAGIC_25976: i64 = 25976
91const NX_MAGIC_32768: i64 = 32768
92const NX_MAGIC_38048: i64 = 38048
93const NX_MAGIC_42361: i64 = 42361
94const NX_MAGIC_46006: i64 = 46006
95const NX_MAGIC_49152: i64 = 49152
96const NX_MAGIC_51916: i64 = 51916
97const NX_MAGIC_54432: i64 = 54432
98const NX_MAGIC_56619: i64 = 56619
99const NX_MAGIC_58744: i64 = 58744
100const NX_MAGIC_60686: i64 = 60686
101const NX_MAGIC_62390: i64 = 62390
102const NX_MAGIC_63984: i64 = 63984
103const NX_MAGIC_65536: i64 = 65536
104const NX_MAGIC_9000: i64 = 9000
105const NX_MAGIC_12000: i64 = 12000
106const NX_MAGIC_8000: i64 = 8000
107const NX_MAGIC_14000: i64 = 14000
108const NX_MAGIC_6553: i64 = 6553
111const NX_WQG_Q: nx_int = 16384
114const NX_WQG_OUT_STRIDE: nx_int = 12
115const NX_WQG_OFF_GRADE: nx_int = 0
116const NX_WQG_OFF_DIVERSITY: nx_int = 1
117const NX_WQG_OFF_LOCAL_VAR: nx_int = 2
118const NX_WQG_OFF_EXTREMES: nx_int = 3
119const NX_WQG_OFF_FLATNESS_PENALTY: nx_int = 4
120const NX_WQG_OFF_FRACTAL_DIM: nx_int = 5
121const NX_WQG_OFF_BIOME_COHERENCE: nx_int = 6
122const NX_WQG_OFF_FEATURE_VARIETY: nx_int = 7
123const NX_WQG_OFF_READABILITY: nx_int = 8
124const NX_WQG_OFF_REFINE_AXIS: nx_int = 9
125const NX_WQG_OFF_MIN_HEIGHT: nx_int = 10
126const NX_WQG_OFF_MAX_HEIGHT: nx_int = 11
129const NX_GRADE_F: nx_int = 0
130const NX_GRADE_D: nx_int = 1
131const NX_GRADE_C: nx_int = 2
132const NX_GRADE_B: nx_int = 3
133const NX_GRADE_A: nx_int = 4
134const NX_GRADE_S: nx_int = 5
135const NX_GRADE_COUNT: nx_int = 6
138const NX_WQG_REFINE_NONE: nx_int = 0
139const NX_WQG_REFINE_MORE_RELIEF: nx_int = 1
140const NX_WQG_REFINE_MORE_FEATURES: nx_int = 2
141const NX_WQG_REFINE_LESS_FLATNESS: nx_int = 3
142const NX_WQG_REFINE_ADD_DETAIL: nx_int = 4
143const NX_WQG_REFINE_SMOOTH_NOISE: nx_int = 5
144const NX_WQG_REFINE_FIX_FRACTAL: nx_int = 6 // fractal dim outside aesthetic band
145const NX_WQG_REFINE_FIX_BIOMES: nx_int = 7 // biome map doesn't match elevation
146const NX_WQG_REFINE_MORE_VARIETY: nx_int = 8 // feature kind histogram too narrow
147const NX_WQG_REFINE_IMPROVE_READ: nx_int = 9 // readability low
148const NX_WQG_REFINE_COUNT: nx_int = 10
151const NX_WQG_HIST_BUCKETS: nx_int = 16
154const NX_WQG_AXIS_WIN_FLOOR: nx_int = 9830 // 0.6Q
155const NX_WQG_AXIS_MARGINAL_FLOOR: nx_int = 6553 // 0.4Q
156const NX_WQG_LOCAL_VAR_UPPER: nx_int = 13107 // 0.8Q
157const NX_WQG_FLATNESS_OK_CEIL: nx_int = 6553 // 0.4Q
158const NX_WQG_FLATNESS_BAD_CEIL: nx_int = 9830 // 0.6Q

functions

164func nx_grade_is_valid(g: nx_int) -> nx_int
called by 1: main
169func nx_wqg_refine_is_valid(r: nx_int) -> nx_int
called by 1: main
175func _wqg_axis_verdict(score: nx_int, floor_win: nx_int, floor_marg: nx_int) -> nx_int
181func _wqg_axis_verdict_banded(
205func _wqg_grade_from_8(
251func _wqg_pick_refine_axis(
301func _wqg_fractal_dim_score(
407func _wqg_biome_expected_band(biome: nx_int) -> nx_int
420func _wqg_biome_coherence_score(
460func _wqg_log2_q14_table(p_bin: nx_int) -> nx_int
480func _wqg_feature_variety_score(
529func _wqg_readability_score(
583func nx_world_quality_grade(
754func main() -> i64