code wiki / (root) / nx_weather_pattern.nx

nx_weather_pattern.nx

buildroot/runtime/nx_weather_pattern.nx

35811 B815 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_weather_pattern.nx -- spatial + temporal weather field. Seventh demonstration of the kind-specific-generator cardinal `feedback-kind-specific-generators-not-broad-noise`. Weather is neither static nor noise -- it has REGIONAL COHERENCE (a single storm cell covers tens of kilometres) and TEMPORAL CYCLES (weeks, seasons). Pure FBM noise gets neither right. Weather-internal logic in v1: - World partitioned into "weather cells" (default 50 km square). All voxels inside one cell share the same weather kind at a given moment. - Time cycles every ~7 game-days: weather changes deterministically per (cell, week) hash. Storms come and go. - 8 sealed-enum weather kinds with characteristic parameters (precipitation, temperature offset, visibility, wind speed, fog density). FULL CAPABILITY (per feedback-maximum-capability-no-simplification cardinal, 2026-05-16): - Smooth spatial transitions via bilinear-blend across the 4 surrounding cell centers (nx_weather_params_smooth) - Per-biome weather distribution (nx_weather_kind_at_biome reweights the kind histogram by biome -- rainforest gets RAIN more often; desert gets HEATWAVE; arctic gets BLIZZARD) - Multi-tick weather evolution: 15% ramp-in + 70% steady + 15% ramp-out within each cycle blends previous, current, next cycle params (nx_weather_evolution_factor + smooth-params) - Wind direction vector (Q14 unit vec dx/dy) per cell+cycle, hashed to one of 16 compass directions; speed from kind params - Lightning discrete events for STORM/BLIZZARD: position + timestamp via deterministic per-cycle hash; composable with nx_world_event Loss audit: cell-based kind discretisation loses sub-cell weather VARIETY (acceptable since real weather IS regionally coherent -- you can't have rain and sun side-by-side in the same valley). PARAMS, by contrast, smooth across cells via bilinear blending so renderer doesn't get sharp transitions.

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_camera_q14.nx nx_weather_pattern.nx

imports: nx_syscalls.nxnx_tier.nxnx_camera_q14.nx

imported by: nobody (leaf or entry point)

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

main nx_weather_kind_is_valid nx_weather_kind_at _wp_hash sys_mmap nx_weather_params nx_weather_at nx_weather_kind_at ↻ nx_weather_params ↻ nx_weather_kind_at_biome _wp_hash ↻ _wp_pick_kind_from_bucket _wp_biome_cumulative nx_weather_evolution_facto _wp_evolution_factor nx_weather_params_smooth nx_weather_evolution_facto ↻ sys_mmap ↻ _wp_hash ↻ _wp_pick_kind_from_bucket ↻ nx_weather_params ↻ nx_weather_wind_at _wp_hash ↻ nx_camera_cos_q14_deg nx_camera_sin_q14_deg _normalise_deg _sin_table_alloc sys_mmap ↻ nx_camera_sin_q14_deg ↻ nx_weather_kind_at_biome ↻ sys_mmap ↻ nx_weather_params ↻ nx_weather_lightning_activ nx_weather_kind_at_biome ↻ _wp_hash ↻

structs

none

consts

56const NX_MAGIC_2654435761: i64 = 2654435761
57const NX_MAGIC_1597334677: i64 = 1597334677
58const NX_MAGIC_951712399: i64 = 951712399
59const NX_MAGIC_7919: i64 = 7919
60const NX_MAGIC_25000: i64 = 25000
61const NX_MAGIC_49999: i64 = 49999
62const NX_MAGIC_5000: i64 = 5000
65const NX_WP_Q: nx_int = 16384
68const NX_WP_LCG_A: nx_int = 48271
69const NX_WP_LCG_M: nx_int = 2147483647
74const NX_WP_DEFAULT_CELL_SIZE_Q14: nx_int = 50000
79const NX_WP_DEFAULT_CYCLE_Q14_DAYS: nx_int = 7
82const NX_WEATHER_CLEAR: nx_int = 0 // sunny, no precip
83const NX_WEATHER_OVERCAST: nx_int = 1 // cloudy, no precip
84const NX_WEATHER_RAIN: nx_int = 2 // moderate liquid precipitation
85const NX_WEATHER_SNOW: nx_int = 3 // moderate frozen precipitation
86const NX_WEATHER_FOG: nx_int = 4 // low visibility, no precip
87const NX_WEATHER_STORM: nx_int = 5 // heavy rain + wind + lightning
88const NX_WEATHER_HEATWAVE: nx_int = 6 // clear + extreme temperature
89const NX_WEATHER_BLIZZARD: nx_int = 7 // heavy snow + extreme wind + low vis
91const NX_WEATHER_KIND_COUNT: nx_int = 8
95const NX_WP_PARAM_PRECIP: nx_int = 0 // Q14 [0, Q]: 0 = dry, Q = monsoon
96const NX_WP_PARAM_TEMP_OFFSET: nx_int = 1 // signed Q14 degrees C from baseline
97const NX_WP_PARAM_VISIBILITY: nx_int = 2 // Q14 [0, Q]: 0 = none, Q = clear
98const NX_WP_PARAM_WIND_SPEED: nx_int = 3 // Q14 [0, Q]: 0 = still, Q = hurricane
99const NX_WP_PARAM_FOG_DENSITY: nx_int = 4 // Q14 [0, Q]: 0 = none, Q = pea soup
101const NX_WP_PARAM_COUNT: nx_int = 5
256const NX_BIOME_TUNDRA: nx_int = 0
257const NX_BIOME_BOREAL_FOREST: nx_int = 1
258const NX_BIOME_GRASSLAND: nx_int = 4
259const NX_BIOME_TEMPERATE_FOREST: nx_int = 5
260const NX_BIOME_DESERT: nx_int = 8
261const NX_BIOME_TROPICAL_RAINFOREST: nx_int = 11
262const NX_BIOME_SNOW: nx_int = 12
263const NX_BIOME_ICE: nx_int = 13

functions

104func nx_weather_kind_is_valid(k: nx_int) -> nx_int
called by 1: main
117func _wp_hash(seed: nx_int, a: nx_int, b: nx_int, c: nx_int) -> nx_int
137func nx_weather_kind_at(
called by 2: nx_weather_atmain calls 1: _wp_hash
174func nx_weather_params(kind: nx_int, out: *i64)
241func nx_weather_at(
275func _wp_biome_cumulative(biome: nx_int, slot: nx_int) -> nx_int
344func _wp_pick_kind_from_bucket(biome: nx_int, bucket: nx_int) -> nx_int
356func nx_weather_kind_at_biome(
384func _wp_evolution_factor(phase_q14: nx_int) -> nx_int
404func nx_weather_evolution_factor(
425func nx_weather_params_smooth(
549func nx_weather_wind_at(
595func nx_weather_lightning_active_at(
643func main() -> i64