code wiki / _hdl_build / nx_evo_breed.nx
nx_evo_breed.nx
buildroot/runtime/_hdl_build/nx_evo_breed.nx
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
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
structs
| none |
consts
| 11 | const EVO_MAGIC_2862933555777941757: i64 = 2862933555777941757 |
| 12 | const EVO_MAGIC_3037000493: i64 = 3037000493 |
| 13 | const EVO_MAGIC_2000000: i64 = 2000000 |
| 14 | const EVO_MAGIC_1000000: i64 = 1000000 |
| 15 | const EVO_MAGIC_1000000000: i64 = 1000000000 |
| 16 | const EVO_MAGIC_2654435761: i64 = 2654435761 |
| 17 | const EVO_MAGIC_12345: i64 = 12345 |
| 19 | const GLEN: i64 = 4 |
| 20 | const EVO_P: i64 = 256 |
| 21 | const EVO_G: i64 = 2000 |
| 22 | const EVO_T: i64 = 5 |
| 23 | const NTRAIN: i64 = 6 |
| 24 | const GCD_CAP: i64 = 256 |
functions
| 26 | func br_rand(state: *i64) -> i64 { state[0] = state[0] * EVO_MAGIC_2862933555777941757 + EVO_MAGIC_3037000493; return (state[0] >> 17) & 0x3fffffff } |
| 27 | func br_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x } |
| 28 | func 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 } |
| 29 | func br_lcm_true(a: i64, b: i64) -> i64 { let g: i64 = br_euclid(a, b); if g == 0 { return 0 } return (a * b) / g } |
| 30 | func 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 } |
| 31 | func 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 } |
| 34 | func gcd_eval(gen: *i64, base: i64, a: i64, b: i64) -> i64 |
| 53 | func gcd_fit(pop: *i64, base: i64) -> i64 |
| 65 | func lcm_eval(pop: *i64, base: i64, a: i64, b: i64, gcdg: *i64) -> i64 |
| 78 | func lcm_fit(pop: *i64, base: i64, gcdg: *i64) -> i64 |
| 89 | func br_fit(pop: *i64, base: i64, phase: i64, gcdg: *i64) -> i64 |
| 93 | func br_tourney(fit: *i64, state: *i64) -> i64 |
| 100 | func br_ga(phase: i64, gcdg: *i64, best: *i64, state: *i64) -> i64 |
| 133 | func 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 } |
| 138 | func br_pn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 140 | func main() -> i64 |