Path Finding ants
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
breed [ants ant] ants-own [ distance_to_home distance_to_target mode speed ] breed [houses house] breed [sugars sugar] directed-link-breed [connections connection] connections-own [ death-time ] to setup clear-all add_house add_sugar create-ants number_of_turtles [ set distance_to_home 0 set distance_to_target 10000 set speed random-float 1.5 set mode "hunt" set color red set shape "bug" set size 0.5 move-to one-of houses ] reset-ticks end to go ask ants [ update_position check_target_reached move_max_distance emit_info ] ask connections [ if ticks >= death-time [die] ] tick end to add_sugar create-sugars 1 [ setxy random-xcor random-ycor move-to one-of patches with [not any? other houses in-radius distance_locations] move-to one-of patches with [not any? other sugars in-radius distance_locations] set color yellow set shape "circle" set size 4 ] end to add_house create-houses 1 [ setxy random-xcor random-ycor move-to one-of patches with [not any? other houses in-radius distance_locations] move-to one-of patches with [not any? other sugars in-radius distance_locations] set color blue set shape "circle" set size 4 ] end to update_position rt random 10 lt random 10 fd speed set distance_to_home distance_to_home + 1 set distance_to_target distance_to_target + 1 end to check_target_reached ifelse (mode = "hunt" and any? sugars-here) [ set distance_to_target 0 set mode "home" set color blue rt 180 ] [if (mode = "home" and any? houses-here) [ set distance_to_home 0 set mode "hunt" set color red rt 180 ]] end to move_max_distance ; check that not lost if (distance_to_home >= max_search_distance and mode = "home") or (distance_to_target >= max_search_distance and mode = "hunt") [ rt random 90 lt random 90 ] end to emit_info let emiter self let clue_distance_home distance_to_home + max_emit_radius let clue_distance_target distance_to_target + max_emit_radius ask ants in-radius max_emit_radius [ ifelse mode = "hunt" and clue_distance_target <= distance_to_target [ set distance_to_target clue_distance_target face emiter if display_links? [ create-connection-from emiter [ set color red set death-time ticks + 5]] ] [if mode = "home" and clue_distance_home <= distance_to_home [ set distance_to_home clue_distance_home face emiter if display_links? [ create-connection-from emiter [ set color blue set death-time ticks + 5]] ]] ] end to setup_avg_plots clear-all-plots end to plot_avg_home let avg-distance-to-home mean [distance_to_home] of ants ; plot the average distance to A plotxy ticks avg-distance-to-home end to plot_avg_target let avg-distance-to-target mean [distance_to_target] of ants ; plot the average distance to B plotxy ticks avg-distance-to-target end to plot_mode_home plotxy ticks count ants with [mode = "home"] end to plot_mode_target plotxy ticks count ants with [mode = "hunt"] end
There is only one version of this model, created over 2 years ago by Leo B.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.