nx_world_quality_grader.nx
buildroot/runtime/nx_world_quality_grader.nx
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
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
structs
| none |
consts
| 84 | const NX_MAGIC_23170: i64 = 23170 |
| 85 | const NX_MAGIC_4096: i64 = 4096 |
| 86 | const NX_MAGIC_8192: i64 = 8192 |
| 87 | const NX_MAGIC_46341: i64 = 46341 |
| 88 | const NX_MAGIC_12288: i64 = 12288 |
| 89 | const NX_MAGIC_16384: i64 = 16384 |
| 90 | const NX_MAGIC_25976: i64 = 25976 |
| 91 | const NX_MAGIC_32768: i64 = 32768 |
| 92 | const NX_MAGIC_38048: i64 = 38048 |
| 93 | const NX_MAGIC_42361: i64 = 42361 |
| 94 | const NX_MAGIC_46006: i64 = 46006 |
| 95 | const NX_MAGIC_49152: i64 = 49152 |
| 96 | const NX_MAGIC_51916: i64 = 51916 |
| 97 | const NX_MAGIC_54432: i64 = 54432 |
| 98 | const NX_MAGIC_56619: i64 = 56619 |
| 99 | const NX_MAGIC_58744: i64 = 58744 |
| 100 | const NX_MAGIC_60686: i64 = 60686 |
| 101 | const NX_MAGIC_62390: i64 = 62390 |
| 102 | const NX_MAGIC_63984: i64 = 63984 |
| 103 | const NX_MAGIC_65536: i64 = 65536 |
| 104 | const NX_MAGIC_9000: i64 = 9000 |
| 105 | const NX_MAGIC_12000: i64 = 12000 |
| 106 | const NX_MAGIC_8000: i64 = 8000 |
| 107 | const NX_MAGIC_14000: i64 = 14000 |
| 108 | const NX_MAGIC_6553: i64 = 6553 |
| 111 | const NX_WQG_Q: nx_int = 16384 |
| 114 | const NX_WQG_OUT_STRIDE: nx_int = 12 |
| 115 | const NX_WQG_OFF_GRADE: nx_int = 0 |
| 116 | const NX_WQG_OFF_DIVERSITY: nx_int = 1 |
| 117 | const NX_WQG_OFF_LOCAL_VAR: nx_int = 2 |
| 118 | const NX_WQG_OFF_EXTREMES: nx_int = 3 |
| 119 | const NX_WQG_OFF_FLATNESS_PENALTY: nx_int = 4 |
| 120 | const NX_WQG_OFF_FRACTAL_DIM: nx_int = 5 |
| 121 | const NX_WQG_OFF_BIOME_COHERENCE: nx_int = 6 |
| 122 | const NX_WQG_OFF_FEATURE_VARIETY: nx_int = 7 |
| 123 | const NX_WQG_OFF_READABILITY: nx_int = 8 |
| 124 | const NX_WQG_OFF_REFINE_AXIS: nx_int = 9 |
| 125 | const NX_WQG_OFF_MIN_HEIGHT: nx_int = 10 |
| 126 | const NX_WQG_OFF_MAX_HEIGHT: nx_int = 11 |
| 129 | const NX_GRADE_F: nx_int = 0 |
| 130 | const NX_GRADE_D: nx_int = 1 |
| 131 | const NX_GRADE_C: nx_int = 2 |
| 132 | const NX_GRADE_B: nx_int = 3 |
| 133 | const NX_GRADE_A: nx_int = 4 |
| 134 | const NX_GRADE_S: nx_int = 5 |
| 135 | const NX_GRADE_COUNT: nx_int = 6 |
| 138 | const NX_WQG_REFINE_NONE: nx_int = 0 |
| 139 | const NX_WQG_REFINE_MORE_RELIEF: nx_int = 1 |
| 140 | const NX_WQG_REFINE_MORE_FEATURES: nx_int = 2 |
| 141 | const NX_WQG_REFINE_LESS_FLATNESS: nx_int = 3 |
| 142 | const NX_WQG_REFINE_ADD_DETAIL: nx_int = 4 |
| 143 | const NX_WQG_REFINE_SMOOTH_NOISE: nx_int = 5 |
| 144 | const NX_WQG_REFINE_FIX_FRACTAL: nx_int = 6 // fractal dim outside aesthetic band |
| 145 | const NX_WQG_REFINE_FIX_BIOMES: nx_int = 7 // biome map doesn't match elevation |
| 146 | const NX_WQG_REFINE_MORE_VARIETY: nx_int = 8 // feature kind histogram too narrow |
| 147 | const NX_WQG_REFINE_IMPROVE_READ: nx_int = 9 // readability low |
| 148 | const NX_WQG_REFINE_COUNT: nx_int = 10 |
| 151 | const NX_WQG_HIST_BUCKETS: nx_int = 16 |
| 154 | const NX_WQG_AXIS_WIN_FLOOR: nx_int = 9830 // 0.6Q |
| 155 | const NX_WQG_AXIS_MARGINAL_FLOOR: nx_int = 6553 // 0.4Q |
| 156 | const NX_WQG_LOCAL_VAR_UPPER: nx_int = 13107 // 0.8Q |
| 157 | const NX_WQG_FLATNESS_OK_CEIL: nx_int = 6553 // 0.4Q |
| 158 | const NX_WQG_FLATNESS_BAD_CEIL: nx_int = 9830 // 0.6Q |
functions
| 164 | func nx_grade_is_valid(g: nx_int) -> nx_int called by 1: main |
| 169 | func nx_wqg_refine_is_valid(r: nx_int) -> nx_int called by 1: main |
| 175 | func _wqg_axis_verdict(score: nx_int, floor_win: nx_int, floor_marg: nx_int) -> nx_int called by 1: nx_world_quality_grade |
| 181 | func _wqg_axis_verdict_banded( called by 1: nx_world_quality_grade |
| 205 | func _wqg_grade_from_8( |
| 251 | func _wqg_pick_refine_axis( called by 1: nx_world_quality_grade |
| 301 | func _wqg_fractal_dim_score( called by 1: nx_world_quality_grade |
| 407 | func _wqg_biome_expected_band(biome: nx_int) -> nx_int called by 1: _wqg_biome_coherence_score |
| 420 | func _wqg_biome_coherence_score( |
| 460 | func _wqg_log2_q14_table(p_bin: nx_int) -> nx_int called by 1: _wqg_feature_variety_score |
| 480 | func _wqg_feature_variety_score( |
| 529 | func _wqg_readability_score( called by 1: nx_world_quality_grade |
| 583 | func nx_world_quality_grade( |
| 754 | func main() -> i64 |