Ant March 2
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This project models the behavior of ants following a leader towards a food source. The leader ant moves towards the food along a random path; after a small delay, the second ant in the line follows the leader by heading directly towards where the leader is located. Each subsequent ant follows the ant ahead of it in the same manner.
Even though the leader may take a very circuitous path towards the food, the ant trail, surprisingly, adopts a smooth shape. While it is not yet clear if this model is a biologically accurate model of ant behavior, it is an interesting mathematical exploration of the emergent behavior of a series of agents following each other serially.
HOW TO USE IT
The SETUP button initializes the model. A brown ant nest is placed on the left side of the world. Inside it are a number of ants (yellow) determined by the NUM-ANTS slider. On the right hand of the world is an orange source of food.
The GO button starts the ants moving. The leader ant (turtle 0) is set in motion roughly in the direction of the food. It wiggles as it moves. That is, it does not head directly towards the food, but changes its heading a random amount to the left or right before it takes each step.
The maximum amount the leader ant can wiggle at each step (and therefore the raggedness of the leader ant's path) is governed by the LEADER-WIGGLE-ANGLE slider. When the leader ant gets close enough to the food to "smell" it, it stops wiggling and heads directly for the food. The leader ant leaves a red trace as it moves.
Each subsequent ant follows the ant ahead of it by heading directly towards it before it takes each step. The follower ants do not leave a trace. The yellow line of ants, however, traces out a curve in the drawing. The last ant to go leaves a blue trace.
The amount of time between ants departing their nest is governed by the START-DELAY slider (plus some random factor).
The ANTS-RELEASED monitor shows you how many ants have left the nest. The other monitor shows you the heading of the lead ant.
THINGS TO NOTICE
How does the shape of the ant line change over time?
How does the path of the initial ant compare with the path of the final ant?
THINGS TO TRY
Try varying the maximum wiggle angle (LEADER-WIGGLE-ANGLE). How does that affect the shape of initial and final ant lines?
Try varying the delay. How does that affect the shape of initial and final ant lines?
How can you slow down the flattening out of the ant line? Can you make the path fail to converge to a straight line?
How can you speed up the flattening out of the ant line?
EXTENDING THE MODEL
How might you keep track of, measure, or plot the flattening process?
What if you relaxed the ant following rules --- maybe add some "wiggle" to their behavior?
NETLOGO FEATURES
Notice the use of delays based on turtle ids in the TIME-TO-START? reporter to make the turtles leave the nest one at a time.
CREDITS AND REFERENCES
The model was inspired by the work of Alfred Bruckstein (see Bruckstein 1993: "Why the ant trails look so straight and nice", The Mathematical Intelligencer, Vol. 15, No. 2).
HOW TO CITE
If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:
- Wilensky, U. (1997). NetLogo Ant Lines model. http://ccl.northwestern.edu/netlogo/models/AntLines. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
COPYRIGHT AND LICENSE
Copyright 1997 Uri Wilensky.
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.
This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.
This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2001.
Comments and Questions
breed [ leaders leader ] breed [ followers follower ] followers-own [igotfood1? ibeengreen? igotfood2?] globals [ nest-x nest-y ;; location of center of nest thing1-x thing1-y ;; obstacle 1 food1-x food1-y ;; location of center of food1 food2-x food2-y ;; location of center of food2 leader-heading ;; heading of the leader ant gotfood1? ;; tells if 50% of turtles got to food1 beengreen? ;; tells if 10% of turtles have been to green1 gotfood2? ;; tells if 90% of turtles got to food2 ] to setup clear-all set-default-shape turtles "bug" set nest-x 10 + min-pxcor ;; set up nest and food locations set nest-y 0 set food1-x 40 + min-pxcor set food1-y 30 set food2-x max-pxcor - 10 set food2-y 0 set thing1-x 60 + min-pxcor set thing1-y -20 ;; draw the nest in brown by stamping a circular ;; brown turtle ask patch nest-x nest-y [ sprout 1 [ set color brown set shape "circle" set size 10 stamp die ] ] ;; draw the food in orange by stamping a circular ;; orange turtle ask patch food1-x food1-y [ sprout 1 [ set color orange set shape "circle" set size 10 stamp die ] ] ;; draw the obstacle in green by stamping a circular ;; green turtle ask patch thing1-x thing1-y [ sprout 1 [ set color green set shape "circle" set size 5 stamp die ] ] ;; draw the second food in orange by stamping a circular ;; orange turtle ask patch food2-x food2-y [ sprout 1 [ set color orange set shape "circle" set size 15 stamp die ] ] create-leaders 1 [ set color red ;; leader ant is red set size 2 wiggle 50 ] ;; ...and starts out with a random heading create-followers (num-ants - 1) [ set size 2 set igotfood1? false set ibeengreen? false set igotfood2? false set color yellow ] ;; middle ants are yellow ask turtles [ setxy nest-x nest-y ;; start the ants out at the nest set heading 90 ] ask turtle (num-ants + 3) [ set color blue ;; last ant is blue set pen-size 2 pd ] ;; ...and leaves a trail ask leaders [ set pen-size 2 pd ] ;; the leader also leaves a trail set leader-heading [heading] of one-of leaders set gotfood1? false set beengreen? false set gotfood2? false reset-ticks end to go if all? turtles [xcor > nest-x - 2 and xcor < nest-x + 2 and ycor > nest-y - 2 and ycor < nest-y + 2] and gotfood2? [ stop ] ask patch nest-x nest-y [ if gotfood2? [ask turtles in-radius 1 [set color brown]]] ask patch food1-x food1-y [ if gotfood1? [ ask followers in-radius 3 [set igotfood1? true] ] if count turtles in-radius 5 > (num-ants * .10) [ set gotfood1? true sprout 1 [ set color green set shape "circle" set size 10 stamp die ] ask leaders [set heading 105] ] ] ask patch thing1-x thing1-y [ if beengreen? [ ask followers in-radius 0 [set ibeengreen? true] ] if count turtles in-radius 1 > (num-ants * .1) [ set beengreen? true ask leaders [facexy food2-x food2-y] ] ] ask patch food2-x food2-y [ if gotfood2? [ ask followers in-radius 3 [set igotfood2? true] ] if count turtles in-radius 3 > (num-ants * .9) [ set gotfood2? true sprout 1 [ set color green set shape "circle" set size 15 stamp die ] ask leaders [facexy nest-x nest-y] ] ] ask leaders ;; the leader ant wiggles and moves [ wiggle leader-wiggle-angle ifelse gotfood2? = false [correct-path][correct-path2] if gotfood1? = false [ if (xcor > (food1-x - 3 )) ;; leader heads straight for food, if it is close [ facexy food1-x food1-y ] if xcor < food1-x ;; do nothing if you're at or past the food [ fd 0.5 ] ] if gotfood1? = true and beengreen? = false [ if (xcor > (thing1-x - 3 )) ;; leader heads straight for food, if it is close ; (xcor > (food2-x - 5 ) [ facexy thing1-x thing1-y ] if xcor < thing1-x ;; do nothing if you're at or past the food [ fd 0.5 ] ] if beengreen? = true and gotfood2? = false [ if (xcor > (food2-x - 3 )) ;; leader heads straight for food, if it is close ; (xcor > (food2-x - 5 ) [ facexy food2-x food2-y ] if xcor < food2-x ;; do nothing if you're at or past the food [ fd 0.5 ] ] if gotfood2? = true [ if (xcor < (nest-x + 3 )) ;; leader heads straight for food, if it is close ; (xcor > (food2-x - 5 ) [ facexy nest-x nest-y ] if xcor > nest-x ;; do nothing if you're at or past the food [ fd 0.5 set leader-wiggle-angle 0 ] ] ] ask followers [ face turtle (who - 1) ;; follower ants follow the ant ahead of them if time-to-start? and (xcor < food1-x) and igotfood1? = false and gotfood2? = false ;; followers wait a bit before leaving nest [ fd 0.5 ] if time-to-start? and (xcor < thing1-x) and gotfood1? = true and gotfood2? = false ;; followers wait a bit before leaving nest [ fd 0.5 ] if time-to-start? and (xcor < food2-x) and beengreen? = true and gotfood2? = false ;; followers wait a bit before leaving nest [ fd 0.5 ] if gotfood2? = true ;; followers wait a bit before leaving nest [ fd 0.5 ] ] set leader-heading [heading] of one-of leaders tick end ;; turtle procedure; wiggle a random amount, averaging zero turn to wiggle [angle] rt random-float angle lt random-float angle end ;; turtle procedure to correct-path ifelse heading > 180 [ rt 180 ] [ if patch-at 0 -5 = nobody [ rt 100 ] if patch-at 0 5 = nobody [ lt 100 ] ] end ;; turtle procedure to correct-path2 if heading < 180 [ rt 180 ] end ;; turtle reporter; if true, then the ant is authorized to move out of the nest to-report time-to-start? report ([xcor] of (turtle (who - 1))) > (nest-x + start-delay + random start-delay ) end ; Copyright 1997 Uri Wilensky. ; See Info tab for full copyright and license.
There are 7 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Ant March 2.png | preview | Preview for 'Ant March 2' | over 10 years ago, by George Dombi | Download |
This model does not have any ancestors.
This model does not have any descendants.
George Dombi
Settling-up a conditional statement. (Question)
This is a model built on top of the original Ant Lines Model. Wilensky, U. (1997). NetLogo Ant Lines model. http://ccl.northwestern.edu/netlogo/models/AntLines. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. I want to extend that model to show a second, sequencial food source. So how do I set up a conditional branch, that once 10% of the original ants reach food source 1, the leader then sets off for food source 2, the other orange dot. I'm trying to understand the use of the primitives All?, Any? and how to make an if/then variable whose true value is 5% of an initial slider value. bye for now, George gDombi@chm.uri.edu
Posted over 10 years ago
Luke Elissiry
Updated Model
Hi George, I have made changes to your model to get the second food pile working. May I recommend that trying to insert additional code into a model built for one task is difficult and is like patching holes (not the funnest coding). Most of what I changed was in the go procedure. I asked the model to stop if all the ants were on food pile 2, asked food pile 1 to set the new global gotfood1? to true when 10% of the ants got to the pile, and asked the leader and followers to run different commands if they were going to pile 1 or pile 2. To expand this model, perhaps have the option to place the food piles where the user wishes. Please ask with any questions. Best Regards, Luke
Posted over 10 years ago
George Dombi
Ants visit 3 sites (Question)
Hi Luke, Thanks, very nice job on getting the ants to the second food pile. I get that it is harder to change someone else's coding rather than making one's own. But for a novice, it is useful to copy the masters's work as budding artists do when they redraw works in an art gallery. I changed the label of the two piles making pile 1 the one closer to the nest and pile 2 the one farther away. That change was not sufficient, but I don't know why. The ants went to pile 1 and refused to go further. My goal is to have the ants follow the leader to pile 1 and when 90% of the ants are there the pile changes color from orange to green. The leader takes off to the next closest pile, the green one, but it is not food, so after 10% of the ants get there, the leader takes off for the second food pile. Once 90% of the ants get to the second food pile, the color turns to green and the leader goes back to the nest, followed by all the other ants.
Posted over 10 years ago
Luke Elissiry
Fixed
Hi George, I made the model to your suggestions above. Please ask any questions you might have. :)
Posted over 10 years ago
George Dombi
Ants come marching home (Question)
Hi Luke, Mighty fine job fixing the Ants Visit 3 Sites model. Upgraded model: Ants come Marching Home. I have changed size of BeenGreen and Food2. Also made ants come straight home from Food2 as they can find their way back along the last trail. Questions: 1) how do I make ants disappear down the hole when they get home, (die)? 2) what is happening at food1 when ants separate? 3) is there a way to gradually change the color of food1 and food 2 from orange to green in stages based on the number of ants present as if they are consuming the food? How do I control the color palette? 4) what is the code for "unstamp" not erase?
Posted over 10 years ago
Luke Elissiry
Some Help
Hi George, 1) I would hide the turtles for this scenario because die causes problems. 2) The ants appear to not be in the range to get igotfood1. 3 + 4) The reason stamp is used is to see the ants when they go onto a pile. Not using stamp, you could ask the pile to check how many ants are around it and set its color depending on number of ants. Example: set color 25 (orange) + count followers in-radius 3 / count followers * 4 (makes pile whiter) Make sure to do a check so when ants leave, color does not get brighter. Sorry for delay, I haven't been able to code much. :)
Posted over 10 years ago
George Dombi
Ants go down the hole
Hi Luke, I have fixed some of my previous concerns especially by helping the ants to get around Food 1. I see that to make the ants disappear down their nest by using the [die] command was a problem as you suggested it might be. I didn't actually solve that problem, but I hid it by making the ants the color of the nest so they appear to go away. Thanks for all your help. On to the next model
Posted over 10 years ago