nx_forest_quality.nx
buildroot/runtime/nx_forest_quality.nx
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
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
structs
| none |
consts
| 36 | const NX_MAGIC_16384: i64 = 16384 |
| 37 | const NX_MAGIC_25976: i64 = 25976 |
| 38 | const NX_MAGIC_32768: i64 = 32768 |
| 39 | const NX_MAGIC_38048: i64 = 38048 |
| 40 | const NX_MAGIC_42361: i64 = 42361 |
| 41 | const NX_MAGIC_46006: i64 = 46006 |
| 42 | const NX_MAGIC_49152: i64 = 49152 |
| 44 | const NX_FQ_Q: nx_int = 16384 |
| 47 | const NX_FQ_TREE_STRIDE: nx_int = 8 |
| 48 | const NX_FQ_OFF_SPECIES: nx_int = 0 |
| 49 | const NX_FQ_OFF_X: nx_int = 1 |
| 50 | const NX_FQ_OFF_Z: nx_int = 3 |
| 51 | const NX_FQ_OFF_CANOPY: nx_int = 5 |
| 52 | const NX_FQ_OFF_AGE: nx_int = 7 |
| 55 | const NX_FQ_AXIS_SPECIES_DIV: nx_int = 0 |
| 56 | const NX_FQ_AXIS_SPACING_REG: nx_int = 1 |
| 57 | const NX_FQ_AXIS_AGE_VAR: nx_int = 2 |
| 58 | const NX_FQ_AXIS_EDGE_PRESENCE: nx_int = 3 |
| 59 | const NX_FQ_AXIS_CANOPY_VAR: nx_int = 4 |
| 60 | const NX_FQ_AXIS_COUNT: nx_int = 5 |
functions
| 63 | func _fq_log2_q14(bin: nx_int) -> nx_int called by 1: _fq_species_diversity_q14 |
| 75 | func _fq_species_diversity_q14(trees: *i64, n: nx_int) -> nx_int |
| 117 | func _fq_spacing_q14( called by 1: nx_forest_quality_grade |
| 163 | func _fq_age_variance_q14(trees: *i64, n: nx_int) -> nx_int called by 1: nx_forest_quality_grade |
| 192 | func _fq_edge_presence_q14( called by 1: nx_forest_quality_grade |
| 235 | func _fq_canopy_variance_q14(trees: *i64, n: nx_int) -> nx_int called by 1: nx_forest_quality_grade |
| 273 | func nx_forest_quality_grade( |
| 295 | func main() -> i64 |