-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple.afa
57 lines (50 loc) · 1.16 KB
/
simple.afa
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
;
; Simple Ant specification in AFA (Assembler for Ants).
;
; This ant walks around, randomly altering its direction on obstacles, and
; alternates between finding food and retrieving food.
;
find-food:
SENSE HERE HOME OR GOTO not-home
TURN LEFT
TURN LEFT
TURN LEFT
GOTO find-food-move
not-home:
PICKUP OR GOTO find-food-move
; implicit continuation to found-food
found-food:
SENSE HERE HOME OR GOTO found-food-move
DROP
TURN LEFT
TURN LEFT
TURN LEFT
GOTO find-food-move
found-food-move:
MOVE OR GOTO recover-found
GOTO found-food
find-food-right:
SENSE RIGHTAHEAD FOOD OR GOTO find-food-left
TURN RIGHT
MOVE OR GOTO recover-find
GOTO find-food
find-food-left:
SENSE LEFTAHEAD FOOD OR GOTO find-food-move
TURN LEFT
MOVE OR GOTO recover-find
GOTO find-food
find-food-move:
MOVE OR GOTO recover-find
GOTO find-food
recover-find:
FLIP 2 OR JUMP 3
TURN RIGHT
GOTO find-food-move
TURN LEFT
GOTO find-food-move
recover-found:
FLIP 2 OR JUMP 3
TURN RIGHT
GOTO found-food-move
TURN LEFT
GOTO found-food-move