Ant sorting

Ant sorting preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Default-person Matteo Lugli (Author)

Tags

ants 

Tagged by Matteo Lugli about 11 hours ago

food 

Tagged by Matteo Lugli about 11 hours ago

sorting 

Tagged by Matteo Lugli about 11 hours ago

swarm intelligenceI 

Tagged by Matteo Lugli about 11 hours ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.4.0 • Viewed 23 times • Downloaded 3 times • Run 0 times
Download the 'Ant sorting' 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 general understanding of what the model is trying to show or explain)

HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

HOW TO USE IT

(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

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

EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

NETLOGO FEATURES

(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

(models in the NetLogo Models Library and elsewhere which are of related interest)

CREDITS AND REFERENCES

(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

turtles-own[
  memory
  drop_rate
  interest
]

to setup
  clear-all
  set-default-shape turtles "bug"
  ;; randomly distribute food
  ask patches
  [ if random-float 100 < density
    [ set pcolor one-of [yellow red blue]] ]
  ;; randomly distribute ants
  create-turtles number [
    set color white
    show memsize
    set memory n-values memsize [black]
    setxy random-xcor random-ycor
    set size 5  ;; easier to see
  ]
  reset-ticks
end 

to go  ;; turtle procedure
  ask turtles[
    update_memory
    ifelse color = white [
      ;; turtle is not carrying anything - look for food
      try-pick-up
    ] [
      ;; turtle is carrying food - look for place to drop it
      try-drop
    ]
    move
  ]
  tick
  if ticks >= max_steps[
    stop
  ]
end 

to try-pick-up
  if pcolor = yellow or pcolor = blue or pcolor = red[
    ; count how many objects I have seen of this color
    let f 0
    foreach memory [ x ->
      if x = pcolor [set f f + 1]
    ]
    set interest greed / (greed + f) ;; prob of being interested
    ;; if I am interested and I have no object, I pick up
    if random-float 1 < interest[
      ifelse color = white
      [
        set color pcolor
        set pcolor black
      ]
      ;; swap current hold item with item on ground otherwise.
      [
        let temp color
        set color pcolor
        set pcolor temp
      ]
      fd escape
    ]
  ]
end 

to try-drop  ;; turtle procedure -- finds empty spot & drops chip
  if pcolor = black
  [
    let f 0
    foreach memory [ x ->
      if x = color [set f f + 1]
    ]
    set drop_rate f / (cons + f)
    if random-float 1 < drop_rate[
      set pcolor color
      set color white
    ]
  ]
end 

to move ; turtle procedure
  fd 1
  rt random 50
  lt random 50
end 

to update_memory ; ant procedure to update memory
  if pcolor != black[
    let index random memsize
    set memory replace-item index memory pcolor
  ]
end 
; Copyright 1997 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created about 11 hours ago by Matteo Lugli.

Attached files

File Type Description Last updated
A_Computational_Model_for_Ant_Sorting.pdf pdf A Computational Model for Ant Sorting about 11 hours ago, by Matteo Lugli Download
Ant sorting.png preview Preview for 'Ant sorting' about 11 hours ago, by Matteo Lugli Download

This model does not have any ancestors.

This model does not have any descendants.