code wiki / _hdl_build / nx_breeding.nx

nx_breeding.nx

buildroot/runtime/_hdl_build/nx_breeding.nx

6762 B162 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_breeding.nx -- certified composable game part: GENETICS / BREEDING (RENAMED from nx_genome.nx 2026-07-26: the basename collided with runtime/nx_genome.nx, an unrelated CREATURE body-plan genome. Two different capabilities, one filename -- whichever a build resolved depended on the include path. Both names were right in their own domain, so the collision was the defect, not either name.) (gamebench capability 30, the Breeders-of-the-Nephelym keystone; program plan Lane B1, board row F1066). A GENOME is a bounded integer trait vector. BREEDING is seeded, deterministic, per-trait inheritance (pick a parent, apply a bounded mutation, clamp to the trait's legal range). This is the axis where a GENERATIVE emitter beats a hand-authored roster BY CONSTRUCTION: a roster is finite; a genome space this size is not (vsbench carries that as HYPOTHESIS until a head-to-head cell measures it -- this part is what makes the hypothesis testable). THE CONTRACT (each clause is a gate tooth): - DETERMINISTIC: same (parents, seed) -> bit-identical child. Replay/lockstep-safe. - BOUNDED HERITABILITY: every continuous trait of a child lies within the parents' span widened by at most the trait's mutation step. Inheritance, not reroll. - UNIQUE OFFSPRING: different seeds -> distinct children (the loottable 0-dup law applied to creatures -- every bred creature is genuinely YOURS, the ownership pillar). - ADULT INVARIANT FAIL-CLOSED: breeding involving a parent below the adult age REFUSES (GN_E_MINOR) with the output untouched, and every emitted child carries age = GN_ADULT_AGE by construction (the nx_card_compile / nx_wardrobe_state law, inherited into the bloodline). - MORPH = the CoC transformation mechanism: a bounded delta to ONE trait, every other word bit-identical -- transformation is a genome edit re-emitted, not a second asset set. - Serializable span rides nx_gamesave like every certified part. LIB, no main (ecosystem convention). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_breeding.nx nx_genome_gate.nx

imports: nx_syscalls.nx

imported by: nx_genome_gate.nx

structs

none

consts

29const GN_T_SPECIES: i64 = 0 // 0..7 humanoid morph archetypes (matches WS_NMORPH)
30const GN_T_SEX: i64 = 1 // 0/1
31const GN_T_BUILD: i64 = 2 // 0..1000 body-proc knob space
32const GN_T_MUSC: i64 = 3
33const GN_T_FAT: i64 = 4
34const GN_T_STYLIZE: i64 = 5
35const GN_T_HUE: i64 = 6
36const GN_T_VIGOR: i64 = 7 // 0..31 IVs (companion lineage)
37const GN_T_INSTINCT: i64 = 8
38const GN_T_TEMPER: i64 = 9
39const GN_T_FERT: i64 = 10
40const GN_T_RARITY: i64 = 11
41const GN_NT: i64 = 12
43const GN_F_AGE: i64 = 0
44const GN_O_TRAIT: i64 = 1 // [1..13)
45const GN_F_LINE: i64 = 13 // lineage hash
46const GN_LEN: i64 = 16
47const GN_ADULT_AGE: i64 = 18
48const GN_SCHEMA: i64 = 1066 // F1066 lineage
50const GN_E_MINOR: i64 = 0-1
51const GN_E_TRAIT: i64 = 0-2
52const GN_E_RANGE: i64 = 0-3
53const GN_CK_SEED: i64 = 2166136261
54const GN_CK_PRIME: i64 = 16777619
55const GN_CK_MASK: i64 = 4611686018427387903
56const GN_SPECIES_JUMP: i64 = 37 // 1-in-37 breedings shift species one step (rare, bounded)

functions

58func gn_mix(c0: i64, v: i64) -> i64
64func gn_hash3(a: i64, b: i64, c: i64) -> i64
called by 2: gn_wildgn_breed calls 1: gn_mix
73func gn_lo(t: i64) -> i64 { return 0 }
74func gn_hi(t: i64) -> i64
80func gn_mut(t: i64) -> i64
called by 2: gn_breedmain calls 2: gn_hign_lo
88func gn_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo { return lo } if v>hi { return hi } return v }
called by 2: gn_breedgn_morph
90func gn_get(g: *i64, t: i64) -> i64 { return g[GN_O_TRAIT + t] }
91func gn_ck(g: *i64) -> i64
called by 1: main calls 1: gn_mix
99func gn_wild(g: *i64, seed: i64, age: i64) -> i64
called by 1: main calls 3: gn_hign_logn_hash3
114func gn_breed(a: *i64, b: *i64, seed: i64, out: *i64) -> i64
142func gn_morph(g: *i64, t: i64, delta: i64) -> i64
called by 1: main calls 4: gn_clampgn_getgn_logn_hi
151func gn_dist(a: *i64, b: *i64) -> i64
called by 1: main calls 3: gn_getgn_hign_lo