-
Notifications
You must be signed in to change notification settings - Fork 1
/
block-222.r4
92 lines (63 loc) · 1.98 KB
/
block-222.r4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
0( Block-222.r4 )
1 bL
10 bL
:HDR "Genetic Evolution"N; cHDR
:NTH 1000+1000/1000*;
0( Each connection is 32 bits )
0( first byte is input, 2nd is output )
0( [type:1][id:7][type:1][id:7][weight:16] )
0(rC: current critter)
25 sNCR 0(Number of critters)
8 sNCN 0(Number of connections - in CELLs)
rNCN 1+ 4* sCSZ 0(Critter size - in BYTES)
150 sWX 0(World size X)
40 sWY 0(World size Y)
rWX rWY * sWSZ 0(World size)
rVH sBSA 1000 cALLOT 0(Brain start address)
rVH sWSA rWSZ cALLOT 0(World start address)
rVH sCSA 0(Critters start address)
:- (x y--n): World get at;
:WGET $rWX*+rWSA+C@;
:- (n x y--): World Set at;
:WSET $rWX*+rWSA+C!;
:- (--): World Init;
:WINIT rWX rWY* rWSA+[0 I C!];
:- (nid--id type): Get neuron id/type;
:NTYPE # h1F b& $ 7R 1 b&;
:0 (nid--): dump neuron info;
:DUMPN cNTYPE "{ type: %d, id: %d }";
:- (--x y) Critter: x y;
:GETXY rC C@ rC P C@;
:- (I--nid) Critter: neuron input connection #I;
:CNI 2L rC+ C@;
:- (I--nid) Critter: neuron output connection #I;
:CNO 2L rC+ P C@;
:- (I--wt) Critter: neuron weight #I;
:CNW 2L rC+ PP @ hFF b&;
:- (I--): Connection dump;
:DUMPCON # cCNI cDUMPN ", " # cCNO cDUMPN cCNW ", wt: ".;
:- (I--): Set Critter, I:[1..N];
:SETCR D rCSZ * rCSA + sC;
:- (x y--): Set X/Y;
:SETXY rC P C! rC C!;
:- (--x y): Random X/Y;
:RANDXY rWX xR rWY xR;
:- (--): Create a random critter;
:RANDCR cRANDXY cSETXY rC 4+ # rNCN 4*+[255 xR I C!];
:- (--): Critter dump connections;
:CDN 1 rNCN["%n " I cDUMPCON];
:- (--): Critter dump;
:DUMPCR cGETXY $ "{ x: %d, y: %d, [" cCDN "]}";
: (--): Dump all critters;
:DUMPALL 1 rNCR[N I #.B cSETCR cDUMPCR];
:- (--): Randomize all critters;
:RANDALL 1 rNCR[I cSETCR cRANDCR];
:- (--): Critter Show;
:SHOWCR cGETXY cGXY rC 7M 31+ 40 cSTC "*";
:- (--): Critter Unshow;
:UNSHOWCR cGETXY cGXY " ";
:- (--): Show all critters;
:SHOWALL 1 rNCR[I cSETCR cSHOWCR] cCLC;
:RL 222bL;
cRANDALL 0(cCLS cCOF 1{\cSHOWALL 0xW K? ~}K@\ cCON)
cDUMPALL