code wiki / _hdl_build / nx_evo_breed.nx

nx_evo_breed.nx

buildroot/runtime/_hdl_build/nx_evo_breed.nx

8072 B170 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic evo
docsdependenciesstructsconstsfunctions

about

nx_evo_breed.nx -- BREEDER: one autonomous run derives a CHAIN of generations, each built on the prior (kids making kids), toward self-sufficiency. GEN 1: derive gcd (2-register Euclid machine). GEN 2: derive lcm using the FRESHLY-derived gcd (this run's gen-1 genome) as a /gcd primitive -> lcm = a*b/gcd. ONE run, two generations, the second COMPOSED FROM the first, Claude NOT in the per-generation loop (only the machine/substrate is authored). Self-verifies each generation vs an independent oracle on a 40x40 grid; prints the lineage. Shared GA: both genomes are 4 ops over 0-5, so one loop drives both phases (fit by phase). license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_evo_breed.nx

imports: nx_syscalls.nxnx_itoa_lib.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 br_ga sys_mmap ↻ br_rand br_fit gcd_fit gcd_eval br_a br_b br_abs br_euclid lcm_fit lcm_eval gcd_eval ↻ br_a ↻ br_b ↻ br_abs ↻ br_lcm_true br_euclid ↻ br_tourney br_rand ↻ gcd_eval ↻ br_euclid ↻ lcm_eval ↻ br_lcm_true ↻ br_p sys_write br_pn nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap sys_exit

structs

none

consts

11const EVO_MAGIC_2862933555777941757: i64 = 2862933555777941757
12const EVO_MAGIC_3037000493: i64 = 3037000493
13const EVO_MAGIC_2000000: i64 = 2000000
14const EVO_MAGIC_1000000: i64 = 1000000
15const EVO_MAGIC_1000000000: i64 = 1000000000
16const EVO_MAGIC_2654435761: i64 = 2654435761
17const EVO_MAGIC_12345: i64 = 12345
19const GLEN: i64 = 4
20const EVO_P: i64 = 256
21const EVO_G: i64 = 2000
22const EVO_T: i64 = 5
23const NTRAIN: i64 = 6
24const GCD_CAP: i64 = 256

functions

26func br_rand(state: *i64) -> i64 { state[0] = state[0] * EVO_MAGIC_2862933555777941757 + EVO_MAGIC_3037000493; return (state[0] >> 17) & 0x3fffffff }
called by 2: br_tourneybr_ga
27func br_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x }
called by 2: gcd_fitlcm_fit
28func br_euclid(a: i64, b: i64) -> i64 { var x: i64 = a; var y: i64 = b; while y != 0 { let t: i64 = x % y; x = y; y = t } return x }
29func br_lcm_true(a: i64, b: i64) -> i64 { let g: i64 = br_euclid(a, b); if g == 0 { return 0 } return (a * b) / g }
called by 2: lcm_fitmain calls 1: br_euclid
30func br_a(i: i64) -> i64 { if i == 0 { return 12 } if i == 1 { return 6 } if i == 2 { return 8 } if i == 3 { return 9 } if i == 4 { return 14 } return 15 }
called by 2: gcd_fitlcm_fit
31func br_b(i: i64) -> i64 { if i == 0 { return 8 } if i == 1 { return 4 } if i == 2 { return 12 } if i == 3 { return 6 } if i == 4 { return 21 } return 10 }
called by 2: gcd_fitlcm_fit
34func gcd_eval(gen: *i64, base: i64, a: i64, b: i64) -> i64
called by 3: gcd_fitlcm_evalmain
53func gcd_fit(pop: *i64, base: i64) -> i64
65func lcm_eval(pop: *i64, base: i64, a: i64, b: i64, gcdg: *i64) -> i64
called by 2: lcm_fitmain calls 1: gcd_eval
78func lcm_fit(pop: *i64, base: i64, gcdg: *i64) -> i64
89func br_fit(pop: *i64, base: i64, phase: i64, gcdg: *i64) -> i64
called by 1: br_ga calls 2: gcd_fitlcm_fit
93func br_tourney(fit: *i64, state: *i64) -> i64
called by 1: br_ga calls 1: br_rand
100func br_ga(phase: i64, gcdg: *i64, best: *i64, state: *i64) -> i64
133func br_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
138func br_pn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
140func main() -> i64