-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple.asl
46 lines (39 loc) · 954 Bytes
/
simple.asl
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
--
-- Simple Ant specification in ASL (Ant Scripting Language)
--
-- This ant walks around, randomly altering its direction on obstacles, and
-- alternates between finding food and retrieving food.
--
function main() {
-- Iterate while navigating to the food.
while (true) {
if (Sense Here Home) {
times(i, 3) {
Turn Left
}
} else if (PickUp) {
break
}
-- When a move is not possible randomly turn left or right
-- until a move is possible
while (!Move) {
moveCell()
}
}
-- Iterate while navigating home.
while (!Sense Here Home) {
moveCell()
}
Drop
}
function moveCell() {
-- When a move is not possible randomly turn left or right
-- until a move is possible
while (!Move) {
if (Flip 2) {
Turn Right
} else {
Turn Left
}
}
}