code wiki / _hdl_build / nx_evo_law_discover_gate.nx
nx_evo_law_discover_gate.nx
buildroot/runtime/_hdl_build/nx_evo_law_discover_gate.nx
dependencies 3 imports · 0 importers
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
structs
| none |
consts
| none |
functions
| 19 | func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw(" calls 1: gw |
| 21 | func rng(st: *i64) -> i64 { st[0]=((st[0]*1103515245)+12345) & 0x7FFFFFFF; return st[0] } |
| 22 | func rng_n(st: *i64, n: i64) -> i64 { return ((rng(st)>>16)&0x7FFF)%n } |
| 24 | func term_eval(rule: i64, x: i64) -> i64 { let r: i64=rule%4; if r==0 { return x } if r==1 { return x*x } if r==2 { return 1 } return 2 } called by 1: main |
| 25 | func term_name(rule: i64) -> *u8 { let r: i64=rule%4; if r==0 { return "x" as *u8 } if r==1 { return "x*x" as *u8 } if r==2 { return "1" as *u8 } return "2" as *u8 } called by 1: cost |
| 26 | func term_cx(rule: i64) -> i64 { if (rule%4)==1 { return 2 } return 1 } called by 1: expr_eval |
| 27 | func op_apply(rule: i64, a: i64, b: i64) -> i64 { let r: i64=rule%3; if r==0 { return a+b } if r==1 { return a-b } return a*b } called by 1: main |
| 28 | func op_name(rule: i64) -> *u8 { let r: i64=rule%3; if r==0 { return "+" as *u8 } if r==1 { return "-" as *u8 } return "*" as *u8 } |
| 29 | func expr_eval(g0: i64, g1: i64, g2: i64, x: i64) -> i64 { return op_apply(g1, term_eval(g0,x), term_eval(g2,x)) } |
| 30 | func mse(g0: i64, g1: i64, g2: i64, X: *i64, Y: *i64, N: i64) -> i64 { var s: i64=0; var i: i64=0; while i<N { let e: i64=expr_eval(g0,g1,g2,X[i])-Y[i]; s=s+(e*e); i=i+1 } return s } |
| 31 | func cost(g0: i64, g1: i64, g2: i64, X: *i64, Y: *i64, N: i64) -> i64 { return (mse(g0,g1,g2,X,Y,N)*1000) + term_cx(g0) + term_cx(g2) } // data-fit + Occam |
| 33 | func main() -> i64 |