Child of Ant Model - Ants to Lines

No preview image

1 collaborator

Emily_warsavage Emily Warsavage (Author)

Tags

(This model has yet to be categorized with any tags)
Child of model Ant Model - Ants to Lines preview imageAnt Model - Ants to Lines
Model group Ant Model Greene Lab | Visible to everyone | Changeable by group members (Ant Model Greene Lab)
Model was written in NetLogo 6.2.0 • Viewed 64 times • Downloaded 7 times • Run 0 times
Download the 'Child of Ant Model - Ants to 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?

A model of T. immigrans (pavement ant) recruitment to a food source, beginning with group-recruitment, when a group of followers follows the leader to the food, and transitioning to mass-recruitment, when foraging is independent of the presence of the leader and based on the pheromone trail.

HOW IT WORKS

The yellow foragers start from the nest and begin exploring the world for the distant food. The first forager to reach the food becomes a leader, returning to the nest and rapidly bringing back follower ants with it. The number of followers is determined by food quality, with the number of followers doubling with each increase in food quality increment (e.g 0.1 - 0.2 food quality). The leader lays down a pheromone trail (trail-markers), which is subsequently reinforced by its followers and other foragers who have successfully found and picked up food, turning orange. Once the maximum number of followers has been collected, the followers break away from the leader, turning purple, and then return to the nest to become foragers, initiating mass-recruitment. At the nest, each successful forager starts a fresh search for food, turning yellow, and recruits an additional forager.

Foragers check for the presence of trail-markers directly ahead of them, and continue forward if they find it. If not, they check for the greatest amount of pheromone trail within a cone of vision to their right or left side and turn accordingly. If they are at the edge, they turn around. If there is no pheromone trail or not enough foragers to trigger mass-recruitment, they walk randomly. Orange foragers use dead-reckoning to return directly to the nest. When the food has been completely consumed, the trail-marker path evaporates, and foragers randomly wander until they encounter the nest. (what rules the agents use to create the overall behavior of the model)

HOW TO USE IT

The food-quality slider controls how many follower ants are recruited, based on increments of 0.2 food-quality units. Foragers do not respond to food with a food-quality of 0, but instead wander randomly through the world. Various monitors report the ticks that correspond to the transformation of the first forager into the leader, when the first follower reaches the food, the time between these ticks, the time when mass-recruitment begins, and when the food is completely reduced.

(how to use the model, including a description of each of the items in the Interface tab)

THINGS TO NOTICE

(suggested things for the user to notice while running the model)

THINGS TO TRY

What does altering the amount of food (at the beginning of the code) do?

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

EXTENDING THE MODEL

Monitor the food level and plot food-level vs time. (suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

NETLOGO FEATURES

Different breeds - types of ants (by default in Netlogo, turtles)

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

RELATED MODELS

The Ants model by Uri Wilensky and Ant Lines model by Uri Wilensky. (models in the NetLogo Models Library and elsewhere which are of related interest)

CREDITS AND REFERENCES

Original basis: Wilensky, U. (1997). NetLogo Ants model. http://ccl.northwestern.edu/netlogo/models/Ants. 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.

Thanks to Jen B of StackOverflow for help with various aspects of the code, especially the leader breed transformation, and the Netlogo Users Group for help with various aspects of the model. Also thanks to Aaron Brandes, a CCL software developer from the Netlogo Users Group, for help with many of the reporters. Thanks to Ted Warsavage for help with troubleshooting and working through model logic. Most of all, thanks to Dr. Michael Greene of UC Denver, who directed this project.

(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;;;;; types of Netlogo turtles, including ants and trail-markers
breed [foragers forager]
breed [leaders leader]
breed [followers follower]
breed [trail-markers trail-marker]

patches-own ;; variables accessible by the patches of the world
[ nest?
  nest-scent
  nest-x nest-y
  food-source-center-x
  food-source-center-y
  food
]

globals  ;; accessible by all agents within the model
[old-sum
  sum-change-tick
  first-follower-food-tick
  first-leader-tick
  food-consumption-tick
  mass-recruitment-tick

  octopamine-level
  octopamine-level-delay-tick
]

to setup
  clear-all
  set-default-shape turtles "bug"
  set-default-shape trail-markers "line half"
  create-foragers 5
  [set color yellow
    set size 2.25
    setxy 36 1]
  setup-patches
;;;                        sets reporters to a default value of -1
  set first-leader-tick -1
  update-first-leader-tick
  set first-follower-food-tick -1
  update-first-follower-food-tick
  set mass-recruitment-tick -1
  update-mass-recruitment-tick
  set food-consumption-tick -1
  update-food-consumption-tick

  set octopamine-level 10
  set octopamine-level-delay-tick -1

  reset-ticks
end 

to setup-patches
ask patches
  [setup-nest
  setup-food
  setup-food-quality]
end 

to setup-nest
    ;; set nest? variable to true inside the nest, false elsewhere
  set nest? (distancexy 36 1) < 2
  ;; spread a nest-scent over the whole world -- stronger near the nest
  set nest-scent 200 - distancexy 36 1
  set nest-x 36
  set nest-y 1
  if nest?
  [set pcolor brown]
end 

to setup-food
  if (distancexy (0.85 * min-pxcor) (0.1 * min-pycor)) < 4.5
  [set food 10                                              ;; dictates the amount of food on each food-patch
    if food > 0
    [set pcolor cyan]]
  set food-source-center-x -32
  set food-source-center-y -2
end 

to setup-food-quality  ;; patch procedure
  if food > 0
  [set food-quality one-of [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]] ;; controllable with slider; 0 triggers no response
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go ;; triggered by the go button
  ask foragers
    [fd 1
     ifelse any? trail-markers
      [ifelse can-move? 1            ;; if not at the edges
        [follow-trail-marker-path]
        [rt 180]]                    ;; if at the edges, turn around
        [wiggle]                     ;; wiggle (random-walk if there is no pheromone trail)
     look-for-food                   ;; respond to food if found
     return-to-nest-and-food
      eliminate-foragers
  ]
  ask leaders
      [wiggle
        lead                                 ;; go back and forth from the nest to the food, collecting followers
        initiate-trail                       ;; lay down trail markers
        mass-recruit-leaders]                ;; transform into foragers once group-recruitment has finished (maximum number of followers collected)
  ask followers
  [follow-leaders                             ;; walk behind leaders
    find-food                                 ;; first follower changes size to signal its presence on the food
    transition-to-mass-recruitment              ;; change color at the end of group recruitment
    return-to-nest-mass-recruitment-transition  ;; break away from the leaders and return to the nest at the end group-recruitment
    mass-recruit]                               ;; transform into foragers after the completion of group-recruitment

  ask patches
  [recolor-patch ]                            ;; change color to signify food-removal

  update-first-leader-tick
  update-first-follower-food-tick
  print word "first-follower-food-tick " first-follower-food-tick
  update-mass-recruitment-tick
  update-food-consumption-tick

  update-octopamine-level-delay-tick

  if sum [food] of patches with [pcolor = cyan] = 0 and ticks > 0        ;; commands for the end of the model
  [if not any? foragers with [color = orange] [ask trail-markers [die]]  ;; evaporate pheromone trail
   ask foragers [if (distancexy nest-x nest-y <= 2) [die]]               ;; re-enter the nest if close
    if count foragers = 0 and ticks > 1000 [stop]]                       ;; stops model

  tick
end 

to look-for-food  ;; forager procedure
  let foods patches with [food > 0]
  let potential-leaders foragers-on foods
  if food > 0 and food-quality > 0
  [ifelse (not any? leaders) and (any? potential-leaders) and (count foragers <= 5)  ;; checks if any leaders exist and if object = true food
  [ ask one-of potential-leaders
    [ set breed leaders
    set color magenta]]  ;; transforms first forager to find food into the leader

    [set color orange]]  ;; identifies all successful foragers after the leader by turning them orange
end 

to return-to-nest-and-food  ;; forager procedure
  if color = orange  ;; directs movement of foragers who have found food
        [if food > 0 and mass-recruitment-tick < 0
          [set food food - .1]          ;; pickup food
          if food > 0 and mass-recruitment-tick > 0
          [set food food - 1]
          if food > 0 and sum [food] of patches with [pcolor = cyan] <= 20
          [set food food - 10]
         if count trail-markers > 200
            [hatch-trail-markers 1       ;; reinforce trail
            [set size 1.0]]
          uphill-nest-scent           ;; directly returns to nest via dead reckoning
          if not can-move? 1 [rt 180]

        if (distancexy nest-x nest-y) <= 2   ;; "drop off" the food at the nest
          [set color yellow                  ;; change back to original color to signal new foraging status
            IF COUNT FORAGERS > 5
            [hatch-foragers 1]                 ;; recruit an additional forager from the nest
            ifelse any? trail-markers [follow-trail-marker-path] [wiggle]
            fd 1
  ] ]
end 

to lead  ;; leader procedure
  if color = magenta
    [fd 2              ;; walks quickly ahead of followers
      uphill-nest-scent ;; dead-reckons
      if (distancexy nest-x nest-y) <= 2
      [set color white
      if food-quality > 0.8
        [if count followers < 10 and (not any? followers with [color = violet + 1]) and (count foragers < 10) ;; hatch n followers, dependent on food-quality
          [if octopamine-level = 0 and ticks >= (first-leader-tick + 100)
            [hatch-followers 1
            [set color brown
        IF count followers = 2
              [fd 1.5]
        IF count followers = 3
              [fd 1.25]
        IF count followers = 4
              [fd 1]
        if count followers = 5
              [fd .9]
        if count followers = 6
              [fd .8]
         if count followers = 7
              [fd .7]
        if count followers >= 8
              [fd .6]  ]]
        ]]

        if (food-quality > 0.6) and (food-quality < 0.9) and (count followers < 8) and (not any? followers with [color = violet + 1]) and (count foragers < 50)
          [if octopamine-level = 0 and ticks >= (first-leader-tick + 100)
            [hatch-followers 1
            [set color brown
        IF count followers = 2
              [fd 1.5]
        IF count followers = 3
              [fd 1.25]
        IF count followers = 4
              [fd 1]
        if count followers = 5
              [fd .9]
        if count followers = 6
              [fd .8]
         if count followers = 7
              [fd .7]
        if count followers = 8
                [fd .6]  ]]]

        if (food-quality > 0.4) and (food-quality < 0.7) and (count followers < 6) and (not any? followers with [color = violet + 1]) and (count foragers < 80)
        [if octopamine-level = 0
          [hatch-followers 1
            [set color brown
        IF count followers = 2
              [fd 1.5]
        IF count followers = 3
              [fd 1.25]
        IF count followers = 4
              [fd 1]
        if count followers = 5
              [fd .9]
        if count followers = 6
              [fd .8]
        ]]]

        if (food-quality > 0.2) and (food-quality < 0.5) and (count followers < 4) and (not any? followers with [color = violet + 1]) and (count foragers < 70)
        [if octopamine-level = 0
          [hatch-followers 1
            [set color brown
        IF count followers = 2
              [fd 1.5]
        IF count followers = 3
              [fd 1.25]
        IF count followers = 4
              [fd 1]
        ]]]

        if (food-quality > 0) and (food-quality < 0.3) and (count followers < 1) and (not any? followers with [color = violet + 1]) and (count foragers < 56)
        [if octopamine-level = 0
        [hatch-followers 1
            [set color brown]]]
  ]]

  if color = white
      [wiggle
        fd 2
        facexy food-source-center-x food-source-center-y        ;; head back to the food
        hatch-trail-markers 1 [set color blue set size 1.0]     ;; lay down pheromone trail
        if food > 0
        [set color magenta] ]
  if not can-move? 1 [rt 180]
end 

to mass-recruit-leaders  ;; transiiton leaders to pheromone-following foragers
  if (not any? followers with [color = brown]) and (distancexy nest-x nest-y <= 2)   ;; transforms leaders into foragers during mass-recruitment
  [if food-quality > 0.8 and count foragers >= 6
    [set breed foragers
      set color yellow
      hatch-foragers 1]
    if food-quality > 0.6 and food-quality < 0.9 and count foragers >= 50
      [set breed foragers
        set color yellow
        hatch-foragers 1]
    if food-quality > 0.4 and food-quality < 0.7 and count foragers >= 70
        [set breed foragers
        set color yellow
        hatch-foragers 1]
    if food-quality > 0.2 and food-quality < 0.5 and count foragers >= 61
      [set breed foragers
        set color yellow
        hatch-foragers 1]
    if food-quality > 0 and food-quality < 0.3 and count foragers >= 54
        [set breed foragers
          set color yellow
          hatch-foragers 1]
  ]
end 

to follow-leaders  ;; follower procedure for group-recruitment
  if color = brown
  [face one-of leaders
    fd 1.75
    hatch-trail-markers 1 [set color blue set size 1.0]      ;; reinforce pheromone trail
  ]
end 

to find-food  ;; follower procedure
  if (distancexy food-source-center-x food-source-center-y < 6) and (count followers = 1) and count foragers < 6 [set size 1.75]  ;; identifies first follower to reach food
end 

to initiate-trail        ;; leader procedure
  ask leaders with [color = magenta]
  [hatch-trail-markers 1
    [set color blue
      set size 1.0]]
end 

to transition-to-mass-recruitment  ;; follower procedure that makes them independent of leaders
  if (distancexy food-source-center-x food-source-center-y <= 6) and (count followers >= 1) and (food-quality < 0.3) ;; once group-recruitment has finished (max number of followers for that food-quality reached)
  [set color violet + 1]

  if (distancexy food-source-center-x food-source-center-y <= 6) and (count followers >= 4) and (food-quality > 0.2) and (food-quality < 0.5)
  [set color violet + 1]

  if (distancexy food-source-center-x food-source-center-y <= 6) and (count followers >= 6) and (food-quality > 0.4) and (food-quality < 0.7)
  [set color violet + 1]

  if (distancexy food-source-center-x food-source-center-y <= 6) and (count followers >= 8) and (food-quality > 0.6) and (food-quality < 0.9)
  [set color violet + 1]

  if (distancexy food-source-center-x food-source-center-y <= 6) and (count followers >= 10) and (food-quality > 0.8)
    [set color violet + 1]
end 

to transition-to-mass-recruitment-old  ;; follower procedure that makes them independent of leaders
  if (distancexy food-source-center-x food-source-center-y) <= 4 and (count followers >= 1) and (food-quality < 0.3) ;; once group-recruitment has finished (max number of followers for that food-quality reached)
  [set color violet + 1]

  if (distancexy food-source-center-x food-source-center-y) <= 4 and (count followers >= 2) and (food-quality > 0.2) and (food-quality < 0.5)
  [set color violet + 1]

  if (distancexy food-source-center-x food-source-center-y) <= 4 and (count followers >= 4) and (food-quality > 0.4) and (food-quality < 0.7)
  [set color violet + 1]

  if (distancexy food-source-center-x food-source-center-y) <= 4 and (count followers >= 8) and (food-quality > 0.6) and (food-quality < 0.9)
  [set color violet + 1]

  if (distancexy food-source-center-x food-source-center-y) <= 4 and (count followers >= 16) and (food-quality > 0.8)
  [set color violet + 1]
end 

to return-to-nest-mass-recruitment-transition  ;; follower procedure that directs them back to nest to initate mass-recruitment
  if color = violet + 1
  [if food > 0
    [set food food - 1]
    hatch-trail-markers 1 [set size 1 set color orange]
    wiggle
    fd 1
    uphill-nest-scent]
end 

to mass-recruit ;; follower procedure for transforming into foragers during mass-recruitment
  if (distancexy nest-x nest-y) <= 2 and (color = violet + 1)
  [set breed foragers
    set color yellow
  hatch-foragers 1]
end 

to recolor-patch  ;; patch procedure
  ;; give color to nest and food sources
  ifelse nest?                          ;; nest? true --> color brown
  [ set pcolor brown ]
  [ ifelse food > 0                     ;; not nest, but has food
    [  set pcolor cyan ]
    [set pcolor black ] ]      ;; food/nest pheromone default to 0
end 

to wiggle            ;; determines the "randomness" of the random walk by having the ants turn any angle up to 45 degress in either direction
  rt random 45
  lt random 45
  if not can-move? 1 [ rt 180 ]
end 

to uphill-nest-scent  ;; dead-reckoning procedure that involves going towards the highest value of nest-scent
  let scent-ahead nest-scent-at-angle   0
  let scent-right nest-scent-at-angle  45
  let scent-left  nest-scent-at-angle -45
  if (scent-right > scent-ahead) or (scent-left > scent-ahead)
  [ ifelse scent-right > scent-left
    [ rt 45 ]
    [ lt 45 ] ]
end 

to follow-trail-marker-path     ;; directs ant movement toward the pheromone trail
  ifelse count foragers < 6    ;; at the beginning of recruitment, foragers weakly follow the pheromone trail and random-walk
  [ifelse any? (trail-markers-on patch-ahead 1) with [color = blue]
    [fd 1]
    [ifelse (patch-left-and-ahead 30 1 = nobody) or (patch-right-and-ahead 30 1 = nobody) or (not any? leaders) or (not any? foragers with [color = orange])
      [rt random 45 lt random 45]
      [if (any? trail-markers-on patch-left-and-ahead 30 1) and (total-trail-markers-in-cone 10 -30 10 > total-trail-markers-in-cone 10 30 10)
        [lt 30]
        if (total-trail-markers-in-cone 10 30 10 > total-trail-markers-in-cone 10 -30 10) and (any? trail-markers-on patch-right-and-ahead 30 1)
        [rt 30]]
  ]]

  [ifelse any? trail-markers-on patch-ahead 1 [fd 1 right random 20 left random 20]
    [ifelse (patch-left-and-ahead 30 1 = nobody) or (patch-right-and-ahead 30 1 = nobody)
      [wiggle]
      [if any? trail-markers-on patch-left-and-ahead 30 1 and (total-trail-markers-in-cone 10 -30 10 > total-trail-markers-in-cone 10 30 10)
        [lt 30]
      if (total-trail-markers-in-cone 10 30 10 > total-trail-markers-in-cone 10 -30 10) and any? trail-markers-on patch-right-and-ahead 30 1
        [rt 30]
        if any? leaders or any? foragers with [color = orange] or count trail-markers > 1000
        [if total-trail-markers-in-cone 5 30 10 < 1 or total-trail-markers-in-cone 5 -30 10 < 1 [uphill-nest-scent]]
        if not any? leaders or not any? foragers with [color = orange] [wiggle]
  ]]]
end 

to eliminate-foragers ;; some ants stuck at the edges die
  if count foragers > 10
  [if patch-here = patch 45 -25 [die]
  if patch-here = patch 45 25 [die]
  ]
end 

;;; checks for any change in various statuses; if there is a change, it will be reported; these primarily correspond to the boxes on the left panel of the model interface

to update-first-leader-tick
  if first-leader-tick < 0
  [show count leaders
    if any? leaders
    [ set first-leader-tick ticks ]
  ]
end 

to update-first-follower-food-tick
  let potential-recruiters followers with [size = 1.75]
  if first-follower-food-tick < 0
    [show count potential-recruiters
    if any? potential-recruiters
    [ set first-follower-food-tick ticks ]
  ]
end 

to update-mass-recruitment-tick
  if mass-recruitment-tick < 0
  [show count followers
    if not any? followers and not any? leaders and count trail-markers > 1000
      [set mass-recruitment-tick ticks]
  ]
end 

to update-food-consumption-tick
  let food-level sum [food] of patches with [pcolor = cyan]
  if food-consumption-tick < 0
  [show food-level
    if food-level < 1
    [ set food-consumption-tick ticks ]
  ]
end 

to update-octopamine-level-delay-tick
if first-leader-tick > 0
  [show octopamine-level-delay-tick

  if octopamine-level = 10 [set octopamine-level octopamine-level - (food-quality * 10)]
  if octopamine-level > 0 and octopamine-level < 10 ;; and not any? followers and count foragers < 6
  [if (ticks - first-leader-tick = 20) or (ticks - first-leader-tick = 40) or (ticks - first-leader-tick = 60) or (ticks - first-leader-tick = 80) or (ticks - first-leader-tick = 100) or (ticks - first-leader-tick = 120) or (ticks - first-leader-tick = 140) or (ticks - first-leader-tick = 160) or (ticks - first-leader-tick = 180)
    [set octopamine-level octopamine-level - 1]]
  ]

  if octopamine-level = 0 and not any? followers and count foragers < 6
      [if ticks = first-leader-tick + 20 or ticks = first-leader-tick + 40 or ticks = first-leader-tick + 60 or ticks = first-leader-tick + 80 or ticks = first-leader-tick + 100 or ticks = first-leader-tick + 120 or ticks = first-leader-tick + 140 or ticks = first-leader-tick + 160 or ticks = first-leader-tick + 180
        [set octopamine-level-delay-tick ticks]]
end 

to-report nest-scent-at-angle [angle]
  let p patch-right-and-ahead angle 1
  if p = nobody [ report 0 ]
  report [nest-scent] of p
end 

to-report total-trail-markers-in-cone [cone-distance angle angle-width ] ; ant procedure - reports the total amount of trail-markers in cone
  rt angle
  let p count trail-markers in-cone cone-distance angle-width
  ;ask p [ show chemical ]
  lt angle
  report (p)
  if not any? p [report 0]
end 

to-report leader-presence
  ifelse any? leaders
  [report first-leader-tick]
  [report -1]
end 

to-report recruitment-delay
  ifelse ticks > 0
  [report first-leader-tick]
  [report -1]
end 

to-report group-recruitment-initiation
  let recruited-ant followers with [size = 1.75]
ifelse any? recruited-ant
  [ report first-follower-food-tick ]
  [ report -1]
end 

to-report leader-food-follower-difference
  ifelse first-leader-tick != -1 and first-follower-food-tick !=  -1
  [ report first-follower-food-tick - first-leader-tick]
  [ report -1 ]
end 

to-report mass-recruitment-initiation
  ifelse not any? followers and not any? leaders
  [report mass-recruitment-tick]
  [report -1]
end 

to-report food-consumption
  ifelse (sum [food] of patches with [pcolor = cyan] < 1 )
  [report food-consumption-tick]
  [report -1]
end 

There is only one version of this model, created over 2 years ago by Emily Warsavage.

Attached files

No files

Parent: Ant Model - Ants to Lines

This model does not have any descendants.

Graph of models related to 'Child of Ant Model - Ants to Lines'