code wiki / (root) / nx_forest_quality.nx

nx_forest_quality.nx

buildroot/runtime/nx_forest_quality.nx

13352 B362 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_forest_quality.nx -- per-kind grader for nx_forest_layout output. Reads a tree array (as emitted by nx_forest_layout_generate or nx_forest_layout_generate_poisson) and grades the forest on 5 axes: 0. SPECIES_DIVERSITY: Shannon entropy of species histogram / log2(n_distinct_species). All-pine forest scores low; mixed deciduous/coniferous scores high. 1. SPACING_REGULARITY: median pairwise distance compared to target (target = sqrt(area / n_trees) for Poisson uniform). Sample pairwise distances on a budget; report 1 - stddev/median. 2. AGE_VARIANCE: stddev of tree ages / Q. Worlds with only mature trees score low (no seedlings); worlds with all seedlings score low (no canopy). 3. EDGE_PRESENCE: fraction of trees within outer [0.85r, r] of region center. Edge-effect ecology demands some boundary density. 4. CANOPY_VARIANCE: stddev of canopy radii. All-same-canopy forests look stamped; varied canopy means age + species variety meet. EMITS LAYER_VERDICT (kind = NX_LAYER_KIND_FOREST). genealogy_id: forest_ecology_canon + shannon_1948_entropy + watt_2008_forest_management lineage_id: nx_forest_quality_5axis_v1

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_layer_verdict.nx nx_forest_quality.nx

imports: nx_syscalls.nxnx_tier.nxnx_layer_verdict.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap nx_forest_quality_grade _fq_species_diversity_q14 sys_mmap ↻ _fq_log2_q14 _fq_spacing_q14 _fq_age_variance_q14 _fq_edge_presence_q14 _fq_canopy_variance_q14 nx_layer_verdict_init nx_layer_verdict_finalize nx_layer_grade_from_axes nx_lv_axis_verdict nx_lv_grade_is_valid

structs

none

consts

36const NX_MAGIC_16384: i64 = 16384
37const NX_MAGIC_25976: i64 = 25976
38const NX_MAGIC_32768: i64 = 32768
39const NX_MAGIC_38048: i64 = 38048
40const NX_MAGIC_42361: i64 = 42361
41const NX_MAGIC_46006: i64 = 46006
42const NX_MAGIC_49152: i64 = 49152
44const NX_FQ_Q: nx_int = 16384
47const NX_FQ_TREE_STRIDE: nx_int = 8
48const NX_FQ_OFF_SPECIES: nx_int = 0
49const NX_FQ_OFF_X: nx_int = 1
50const NX_FQ_OFF_Z: nx_int = 3
51const NX_FQ_OFF_CANOPY: nx_int = 5
52const NX_FQ_OFF_AGE: nx_int = 7
55const NX_FQ_AXIS_SPECIES_DIV: nx_int = 0
56const NX_FQ_AXIS_SPACING_REG: nx_int = 1
57const NX_FQ_AXIS_AGE_VAR: nx_int = 2
58const NX_FQ_AXIS_EDGE_PRESENCE: nx_int = 3
59const NX_FQ_AXIS_CANOPY_VAR: nx_int = 4
60const NX_FQ_AXIS_COUNT: nx_int = 5

functions

63func _fq_log2_q14(bin: nx_int) -> nx_int
75func _fq_species_diversity_q14(trees: *i64, n: nx_int) -> nx_int
117func _fq_spacing_q14(
163func _fq_age_variance_q14(trees: *i64, n: nx_int) -> nx_int
192func _fq_edge_presence_q14(
235func _fq_canopy_variance_q14(trees: *i64, n: nx_int) -> nx_int
273func nx_forest_quality_grade(
295func main() -> i64