-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZoe.txt
executable file
·250 lines (250 loc) · 6.48 KB
/
Zoe.txt
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
* Zoe
* ZoeL
* Machine model
* Each bug is a stack-based processor executing VitaL, which is
modeled after Wirth's pcode.
* During each world cycle, each bug on the run queue is
executed until it issues one of the turn-ending
instructions:
* Loiter
* Bite
* Move
* Fork
Bugs executing ridiculously many instructions without
ending their turn are paralyzed -- removed from the run
queue.
* In addition to the stack, each bug can access its own
registers and the registers of the bug it has most
recently sensed. The former are referenced as
$<register>, and the latter are referenced as
$$<register>.
* Cycle
How many world cycles have executed.
* Name
The bug's unique ID. ID's are assigned by birth order.
* Surname
The ID of the bug's species.
* Strength
How much energy the bug has. Energy is used for
moving, eating, breeding, and breathing.
* Size
How big the bug is. Size affects the energy cost of
moving, breeding, and breathing. Size affects whether
a bug can be noticed/bitten by a given other bug.
* Age
How many world cycles the bug has been executed.
* Heading
The direction the bug will move if it issues a Move
instruction. An integer from 0 to 359. 0 is right
(increasing x), 90 is down (increasing y).
* Gaze
The direction to the last thing sensed. An integer
offset from $Heading.
* X
* Y
The bug's coordinates, rounded to the nearest integer.
* Ancestor
'Distance' from the bug to the most-recently-sensed bug
in the individual ancestry graph. Distance is measured
to the nearest common ancestor. If the MRS bug is a
descendant, the distance is negative. If the bug is
unrelated, the distance is MAX_INT.
* Phylogenitor
Like $Ancestor, except for species instead of individuals.
* Instruction Set
* Loiter
* Eat
Push amount eaten
* Bite
* amount eaten is <= $Strength/2
* Bugs 1/10 your size or smaller are not edible
* Move
* Turn [direction]
* Sets $Heading
* direction ::= <degrees offset from $Heading>
* direction ::= $Gaze
* with no arg, $Heading += popped offset
* Move
Move along $Heading one unit, with $Strength decremented
by a function of $Size
* Sense
* Look
* Feel
* Feel range = 1; Look range = 5
* pushes number of things sensed
* loads $Gaze with direction of biggest sensation
* if nothing sensed, $Gaze set to zero
* Bugs 1/10 your size or smaller are not visible
* Reproduce
* Fork [childSizePct]
* only succeeds if strong enough to breed
* pushes size of child (or zero on failure)
* child
* gets a copy of parent's stack
* gets a (possibly mutated) copy of parent's program
* inherits parent's program counter
* gets a random $Heading
* $Gaze set toward parent
* $Size set to minSize of species
* $Strength set to half parent's remaining strength; i.e.,
($$Strength - $Size - breedTax)/2
* pushes $Surname of parent
* parent
* $Gaze set toward child
* pushes $Surname of child
* decrements $Strength by amount invested in child
* Stack
* Random [modulus]
Pushes random integer modulo the argument (or popped) modulus
* Load n
* Load $[$]register
* Pop
* Swap
* Dup
* Operators
Stack top is 'left' argument of binary operators.
* Add
* Sub
* Mul
* Div
* And
* Or
* Not
* Neg
* Abs
* Eq
* Neq
* Lss
* Leq
* Gtr
* Geq
* Output
* Msg ["string"]
Prints string [or popped value]
* Example bugs
* Plant
_genes {
Graze
Graze
Graze
Graze
Fork
}
* Flytrap
_genes {
Feel 0
Not
If 1
Bite
Jump -1
Label
Graze
Random 100
If 1
Fork 1
}
* Roadrunner
_genes {
/* If we're in biting range, run! */
Feel 0
Not
If 1
Msg "Meep! Meep!\n"
Move
Jump -1
Label
/* If we're near another bug, run! */
Feel 1
Not
If 1
Turn $Gaze
Turn 180
Msg "Meep! Meep!\n"
Move
Jump -2
Label
/*
* We're safe. Eat as long as there is food,
* try to fork, and then move on.
*/
Graze
If -1
Fork 4
Move
}
* Borg
_genes {
Feel 0
Not
If 1
Load $Phylogenitor
Not
If 5
Bite
Not
If -1
Msg "Mmm, bug"
Msg $$Name
Msg " tastes good!\n"
Jump -1
Label
Feel 1
Not
If 1
Load $Phylogenitor
Not
If 4
Load $$Strength
Load $Strength
Lss
If 4
Turn $Gaze
Move
Jump -2
Label
Feel 2
Not
If 1
Load $Phylogenitor
Not
If 3
Load $$Strength
Load $Strength
Lss
If 3
Turn $Gaze
Move
Jump -3
Label
Look 5 0 180
Not
If 1
Load $Phylogenitor
Not
If 2
Load $$Strength
Load $Strength
Lss
If 2
Msg "Bug"
Msg $$Name
Msg ", you will be assimilated. Resistance is futile.\n"
Turn $Gaze
Move
Jump -4
Label
Graze
Pop
Fork 0
Move
Not
If 2
Label
Turn 90
Move
Move
Move
Move
Move
Move
}