-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUSCAnt.bug
More file actions
33 lines (27 loc) · 1.04 KB
/
USCAnt.bug
File metadata and controls
33 lines (27 loc) · 1.04 KB
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
colony: USCAnt // first line specifies the ant's name
// This program controls a single ant and causes it to move
// around the field and do things.
// This ant moves around randomly, picks up food if it
// happens to stumble upon it, eats when it gets hungry,
// and will drop food on its anthill if it happens to
// stumble back on its anthill while holding food.
// here's the ant's programming instructions, written
// in our 'Bugs' language
start:
faceRandomDirection
moveForward
emitPheromone
if i_am_standing_on_food then goto on_food
if i_am_hungry then goto eat_food
if i_am_standing_on_my_anthill then goto on_hill
goto start // jump back to the "start:" line
on_food:
pickUpFood
goto start // jump back to the "start:" line
eat_food:
eatFood // assumes our ant has already picked up food
goto start // jump back to the "start:" line
on_hill:
dropFood // feed the anthill's queen so she
// can produce more ants for the colony
goto start // jump back to the "start:" line