The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.
powered by NetLogo
view/download model file: AntPiles.nlogo
This is a demo of how simple commands can result in complex behavior.
An ant is colored white if he is carrying nothing, and blue if he is carrying food.
Empty ground is black, and food is yellow.
Each ant knows only a few commands…
Wander randomly,
If you come across some food, do one of two things..
If you are not carrying food, pick it up.
If you are already carrying food, drop the food.
The slider for “number of ants” selects how many ants you want to walk around. A good number is 500.
The slider for “ground-cover” selects the percentage of ground covered by food. A good value is 10%.
The “setup” draws the world, the ants and distibutes the food.
The “go” button starts the simulation.
You can make use of the slider at the top to control the speed of the simulation.
The ants will quickly start forming piles of food. As the piles grow, they will assimilate any smalls piles close by. Small piles will disappear as the larger ones grow. Eventually there will only be one large pile.
Varying the percentage of ground cover and the number of ants.
Next will be to have ants collect different types of food and stack them in separate piles. This will be a form of sorting.
Termites by Uri Wilensky
;;piles-versian 14- compleate new rewrite
breed [ants ant]
ants-own [need-to-drop]
to setup
;; (for this model to work with NetLogo's new plotting features,
;; __clear-all-and-reset-ticks should be replaced with clear-all at
;; the beginning of your setup procedure and reset-ticks at the end
;; of the procedure.)
__clear-all-and-reset-ticks
set-default-shape ants "bug"
ask patches
[ if random-float 100 < ground-cover
[ set pcolor yellow ] ]
create-ants number-of-ants [
set color white
setxy random-xcor random-ycor
set size 5
]
end
to go ;; ant procedure
ifelse pcolor = yellow ; ant is standing on food
[ if color = blue ;;a blue ant is carrying
[
set need-to-drop 1
walk
]
if color = white ; ant is not carrying
[
set pcolor black
set color blue
walk
]
] ;;end of if pcolor is yellow
;;This means the ant is on ground, not food
[
ifelse need-to-drop = 1
[
set pcolor yellow
set color white
set need-to-drop 0
walk
fd 20
]
[
walk
]
] ;;end of if pcolor is yellow else
end
to walk ; ant walking procedure
rt random 50
lt random 50
fd 1
end