Sustainable_Village
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
;;INCLUDE FILES;; ;;__includes["Agent_Script.nls" "Village_Script.nls" ] breed [trees tree] breed [berries berry] breed [animals animal] breed [houses house] breed[villagers villager] ;;TURTLE VARIABLES;; turtles-own[ food energy ] ;;GLOBAL VARIABLES;; globals [ wood village-food village-wood ] ;;SETUP FUNCTION;; to setup clear-all setup-village ;;setup village setup-agents ;;setup agents ;;reset-ticks ;;setup-trees set-default-shape houses "house" create-houses 1 [ set color brown set size 2.5 set energy 0 setxy random-xcor random-ycor ] set-default-shape trees "tree" create-trees initial-number-trees [ set color green set size 1.5 ;;set energy 0 setxy random-xcor random-ycor ] set-default-shape berries "circle" create-berries initial-number-berries [ set color red set size 0.5 set energy 0 setxy random-xcor random-ycor ] set-default-shape animals "sheep" create-animals initial-number-animals [ set color white set size 1 set energy 0 setxy random-xcor random-ycor ] ;;display-labels reset-ticks end to setup-trees ;;create-trees 50 [ setxy random-xcor random-ycor ] end to build-house if wood >= 10 [ set wood 0 hatch 1 ] end ;;GO FUNCTION;; to go choose-action ;; have agents wander around the map tick end to setup-agents set-default-shape turtles "person" create-villagers population [ set-agent-stats if energy < 25 [set energy energy + 60] setxy random-xcor random-ycor set color pink ] end to gather-food set color red if any? berries in-radius 1 [ask berries in-radius 2 [die] ;;set food food + 1 set energy energy + random 50 ifelse energy < 25 ; only eat the food if hungry, else give to village [ set energy energy + random 50 ] [ set village-food village-food + 1 ] ] end to gather-wood set color brown if any? trees in-radius 1 [ask trees in-radius 2 [die] set wood wood + 2] end to wander fd 1 rt random 80 lt random 80 set energy energy - 1 end to choose-action ask villagers[ set label energy wander (ifelse energy < 40[gather-food]energy > 75[gather-wood][set color pink]) if energy <= 0 ; if out of energy, try and eat from the village food, or else die [ ifelse village-food > 0 [ set energy energy + random 50 set village-food village-food - 1 ] [die] ] ] end to set-agent-stats set size 1 set food 0 set wood 0 set energy 100 end to setup-village set village-food initial-village-food ;set village-wood initial-village-wood ;; not added yet end
There are 3 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Sustainable_Village.png | preview | Preview for 'Sustainable_Village' | over 4 years ago, by Marco McAlindin | Download |
This model does not have any ancestors.
This model does not have any descendants.