Sustainable_Village_AI
Model was written in NetLogo 6.2.0
•
Viewed 66 times
•
Downloaded 6 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
;;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 < 35 [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 random 90 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_AI.png | preview | Preview for 'Sustainable_Village_AI' | about 3 years ago, by Marco McAlindin | Download |
This model does not have any ancestors.
This model does not have any descendants.