code wiki / _hdl_build / nx_genetic_algorithm_gate.nx

nx_genetic_algorithm_gate.nx

buildroot/runtime/_hdl_build/nx_genetic_algorithm_gate.nx

6496 B88 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

dependencies 3 imports · 0 importers

nx_gate_gn.nx nx_gate_base.nx nx_syscalls.nx nx_genetic_algorithm_gate.nx

imports: nx_gate_gn.nxnx_gate_base.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main gw sys_write sys_mmap rng_n rng gn popcount crossover rng_n ↻ mutate rng_n ↻ sys_exit

structs

none

consts

none

functions

19func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
calls 1: gw
21func rng(st: *i64) -> i64 { st[0]=((st[0]*1103515245)+12345) & 0x7FFFFFFF; return st[0] }
called by 3: crossovermutatemain calls 1: rng
22func rng_n(st: *i64, n: i64) -> i64 { return rng(st)%n }
called by 1: main
23func popcount(x: i64, L: i64) -> i64 { var c: i64=0; var i: i64=0; while i<L { if ((x>>i)&1)==1 { c=c+1 } i=i+1 } return c }
called by 1: main calls 1: rng_n
24func crossover(a: i64, b: i64, L: i64, st: *i64) -> i64 { let pt: i64=rng_n(st,L); let lowmask: i64=(1<<pt)-1; let full: i64=(1<<L)-1; return (a & lowmask) | (b & (full - lowmask)) }
called by 1: main calls 1: rng_n
25func mutate(x: i64, L: i64, st: *i64) -> i64 { if rng_n(st,100)<25 { let bit: i64=rng_n(st,L); return (x ^ (1<<bit)) & ((1<<L)-1) } return x }
27func main() -> i64