Ant Lines

Ant Lines preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

ants 

Tagged by Reuven M. Lerner almost 12 years ago

biology 

Tagged by Reuven M. Lerner over 11 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 962 times • Downloaded 106 times • Run 3 times
Download the 'Ant Lines' modelDownload this modelEmbed this model

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 Institute on Complex Systems, Northwestern University, Evanston, IL.
  • Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.

COPYRIGHT AND LICENSE

Copyright 1997 Uri Wilensky.

CC BY-NC-SA 3.0

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

Click to Run Model

breed [ leaders leader ]
breed [ followers follower ]

globals [
  nest-x nest-y    ;; location of center of nest
  food-x food-y    ;; location of center of food
  leader-heading   ;; heading of the leader ant
]

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 food-x max-pxcor - 10
  set food-y 0
  ;; 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 nest in orange by stamping a circular
  ;; orange turtle
  ask patch food-x food-y [
    sprout 1 [
      set color orange
      set shape "circle"
      set size 10
      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 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 - 1)
    [ 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
  reset-ticks
end 

to go
  if all? turtles [xcor >= food-x]
    [ stop ]
   ask leaders                                      ;; the leader ant wiggles and moves
     [ wiggle leader-wiggle-angle
       correct-path
       if (xcor > (food-x - 5 ))                    ;; leader heads straight for food, if it is close
         [ facexy food-x food-y ]
       if xcor < food-x                             ;; do nothing if you're at or past the food
         [ fd 0.5 ] ]
   ask followers
     [ face turtle (who - 1)                        ;; follower ants follow the ant ahead of them
       if time-to-start? and (xcor < food-x)        ;; 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 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 10 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky about 12 years ago Updated version tag Download this version
Uri Wilensky about 12 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky almost 13 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Model from NetLogo distribution Download this version
Uri Wilensky over 14 years ago Ant Lines Download this version

Attached files

File Type Description Last updated
Ant Lines.png preview Preview for 'Ant Lines' over 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.