The applet requires Java 1.4.1 or higher. It will not run on Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use a browser that supports Java 1.4. (Safari works, IE does not. Mac OS X comes with Safari. Open Safari and set it as your default web browser under Safari/Preferences/General.) On other operating systems, you may obtain the latest Java plugin from Sun's Java site.
powered by NetLogo
view/download model file: odd_protocol_on_a_closed_world.nlogo
Our simulation has the objective to test a lot of scenarios in a closed and simple society, by changing the main characteristics of the world. The important endogenous factor avoiding a predictable result is the emerging of epidemics. Such a world will be termed unstable if it tends to the collapse of the population. At the opposite, the system would be stable if it tends to maintain itself over time, despite fluctuations in population sizes.
Farmer-agents pursue their own aims: eating and reproducing. At the same time, increasing in number, they have to cope with the limitation of resources of the world even worsen by the correspondent increment in building of houses. Giving them the capability of seeing within a bigger radius helps them to better manage with the resources. The "TORNADO" button just delays the effects in progress.
There are no predetermed frameworks of evolution of the model, but you can try to firstly modify the most effective parameters such as: "vision-range", "vegetation regrowth time" and "energy from food" to see their different effects.
0. If you want, you can set default values by clicking the "setup-default-values" button.
1. Press the SETUP button.
2. Press the GO button to begin the simulation.
3. Look at the monitors to see the current population size, the number of farmers, the number of ill farmers, the number of houses to create and the current number of houses.
4. Look at he "WORLD" plot to watch how inhabitants, food, ill people and fluctuate over time.
- "lifespan": the maximum duration of a farmer's life
- "initial_number": the initial number of farmers
- "birth_probability": the probability that a new turtle is created from an inhabitant that has energy enough
- "vision-range": the capability of turtles to see within a certain radius
- "energy_from_food": the amount of energy turtles get for every green patch eaten
- "vegetation_regrowth_time": how long it takes for fruits and vegetables to regrow once they are eaten
- "num_of_doctors": the number of doctors
- "persons_per_house": persons that live in the same house
- "prob_of_sickness_when_malnourished": probability of getting ill when being malnourished
- "show-energy?": whether or not to show the energy of each farmer as a number.
- one unit of energy is deducted for every step a farmer takes, but when it gets sick, five units are deducted
- every tick farmers become older of 0.15 of a year
- the "cost" of a birth is 30 energy points for the creating turtle.
The button "setup-default-variables" set all sliders and switches to the values we thought could have been quite normal in a Middle Age society.
The “TORNADO” button destroys a random portion of the world including houses, food and people. In detail, it is shaped as a quadrilateral with random length sides (between 5 and 20 patches).
The switch "show-energy?", when it is set on, highlights the energy level of each turtle.
Try adjusting the parameters under various settings. How sensitive is the stability of the model to the particular parameters?
Try to set the "num_of_doctors" equal to zero; the society will collapse because of the emergence of epidemics and the speed at which population becomes extinct.
Another important slider to change the evolution of the world is vision-range, that allows people to optimise the use of the present resources through the capability of having a look to far green patches.
Via the "birth_probability" slider, you can control the births of new farmers. In other words it's the probability for a turtle to create a new one when its energy is higher than 60.
Last, but not the least, try to move the "vegetation_regrowth_time" slider to modify the speed at which vegetation grows, it will surely have strong effects as far as the population is concerned.
It would be interesting trying to add the difference of gender in the population and even in the doctors community so as to see how they manage with an eventual lack of males or females.
You could also try to make people to go from home to the food and then back without eating while walking.
Another very important tool to increase the possibility of surprises in the model would be the emerging of scientific innovations.
Note the use of breeds to model two different kinds of "turtles": people and doctors. Note the use of patches to model grass, eaten vegetation and houses.
Note the "TORNADO" procedure. Just to make its results as unpredictable as possible, we used a function to create every time random numbers in an interval. That is:
x = a + random (b - a) ; it yields x values >=a and <b.
Look at Wolf Sheep predation and Virus from the Models library. They both cope with just one of the problems we present in our model: the former is about limited resources and the latter about virus spreading.
- Tainter, Joseph A. (1990). The Collapse of Complex Societies. Cambridge: Cambridge University Press. ISBN 0-521-38673-X.
- Diamond, Jared Mason. (2005) Collapse: How Societies Choose to Fail or Succeed. New York: Viking Books. ISBN 1-586-63863-7
globals [fruits_vegetables current-number-houses num-of-houses-to-create num-of-farmers] breed [farmers person_farmer] breed [doctors person_doctor] farmers-own [energy age sick?] doctors-own [energy age] patches-own [countdown] to setup clear-all setup-world setup-farmers setup-doctors update-plot end to setup-default-values set lifespan 3000 set initial_number 30 set birth_probability 70 set vision-range 2 set energy_from_food 40 set vegetation_regrowth_time 100 set num_of_doctors 15 set persons_per_house 10 set prob_of_sickness_when_malnourished 30 set show-energy? false end to go if not any? farmers [ stop ] ask farmers [ move eat-fruits_vegetables get-sick infect reproduce-farmers create-houses aging death ] ask patches [ grow-fruits_vegetables ] ask doctors [ move-doctor cure eat-fruits_vegetables ] tick update-plot display-labels end to setup-farmers set-default-shape farmers "person_farmer" create-farmers initial_number [ set color black ;; create the inhabitants, then initialize their variables set energy random (energy_from_food) setxy random-xcor random-ycor set age random lifespan move ] end to setup-doctors set-default-shape doctors "person_doctor" create-doctors num_of_doctors [set color white setxy random-xcor random-ycor set energy random (energy_from_food) move-doctor] end to setup-world set-patch-size 14 ask patches [set countdown random vegetation_regrowth_time] ;; initialize fruits and vegetables grow clocks randomly ask patches with [pxcor > -16 and pxcor < 16 and pycor < 16 and pycor > -16][set pcolor one-of [green brown]] ask patches with [pxcor = -16][set pcolor blue] ask patches with [pxcor > -16 and pycor > 15][set pcolor gray] ask patches with [pxcor = 16][set pcolor gray] ask patches with [pxcor > -16 and pycor < -15][set pcolor gray] set current-number-houses (initial_number / persons_per_house) ask n-of current-number-houses patches with [pcolor != blue and pcolor != gray][set pcolor red] end to create-houses set num-of-farmers (count farmers) set num-of-houses-to-create (num-of-farmers / persons_per_house - current-number-houses) if num-of-houses-to-create > 1 [ask n-of num-of-houses-to-create patches with [pcolor != blue and pcolor != gray][set pcolor red]] set current-number-houses (count patches with [pcolor = red]) energy-to-create-houses end to energy-to-create-houses if num-of-houses-to-create > 1 [ ask n-of num-of-houses-to-create farmers [set energy energy - 10] ] end to move see let movement random-float 10 while [movement > 0] [ifelse movement >= 1 [fd 1] [fd movement] if pcolor = blue or (pcolor = gray) [set heading heading + 180 while [pcolor = blue or (pcolor = gray)] [fd 1] ] set movement movement - 1] ifelse sick? = false [ set energy energy - 1 ] [ set energy energy - 5 ] end to see let candidates patches in-radius vision-range with [ pcolor = green ] ifelse any? candidates [ face one-of candidates ] [ rt random 360 ] end to move-doctor let movement random-float 10 while [movement > 0] [ifelse movement >= 1 [fd 1] [fd movement] if pcolor = blue or (pcolor = gray) [set heading heading + 180 while [pcolor = blue or (pcolor = gray)] [fd 1] ] set movement movement - 1] end to eat-fruits_vegetables ;; farmers eat fruits and vegetables, turn the patch brown if pcolor = green [ set pcolor brown set energy energy + energy_from_food ;; farmers gain energy by eating ] end to reproduce-farmers ask farmers [ if energy > 60 [ if sick? = false [ if random-float 100 < birth_probability [ set energy energy - 30 hatch 1 [ ;; hatch an offspring and move it forward 1 step rt random-float 360 fd 1 set age 0 set energy 30] ] ] ] ] end to aging set age age + 0.15 end to death if energy <= 0 [ die ] ;; when energy dips below or equal zero, die if age > lifespan [die] ;; when the age is greater than lifespan the turtle dies end to get-sick if energy <= 20 [ if random 100 < prob_of_sickness_when_malnourished [ set sick? true set color yellow ] ] end to infect if sick? = true [ask other farmers-here [if random-float 100 < 50 [be-sick]]] end to be-sick set sick? true end to cure let patient one-of farmers-here if patient != nobody [ask patient [be-sane]] end to be-sane set sick? false set color black end to grow-fruits_vegetables ;; patch procedure if pcolor != red [ ;; countdown on brown patches: if reach 0, grow some fruits_vegetables if pcolor = brown [ ifelse countdown <= 0 [ set pcolor green set countdown vegetation_regrowth_time ] [ set countdown countdown - 1 ] ]] end to update-plot set-current-plot "World" set-current-plot-pen "Number of houses" plot count patches with [pcolor = red] set-current-plot-pen "Total number of people" plot count turtles set-current-plot-pen "Number of ill farmers" plot count farmers with [sick? = true] set-current-plot-pen "Food" plot count patches with [pcolor = green] end to display-labels ask farmers [ set label "" ] if show-energy? [ ask farmers [ set label round energy ] ] end ;;the tornado is going to destroy a random area in the world, ;;moreover it is going to be shaped as a quadrilateral with random length sides (between 5 and 20 patches) to tornado let area-tornado-x random-xcor ;;generate a random number between -16 and 16, this number is going to be the lower left corner x coordinate of the tornado area let area-tornado-y random-ycor ;;generate a random number between -16 and 16, this number is going to be the lower left corner y coordinate of the tornado area let width-tornado-x 10 + random 15 ;;in order to generate a random number >= a and < b we used the following formula x = a + random (b - a) let width-tornado-y 10 + random 15 ;;generate a random number between 10 and 25 ask farmers with [pxcor > area-tornado-x and pxcor < (area-tornado-x + width-tornado-x) and pycor > area-tornado-y and pycor < (area-tornado-y + width-tornado-y)] [die] ask doctors with [pxcor > area-tornado-x and pxcor < (area-tornado-x + width-tornado-x) and pycor > area-tornado-y and pycor < (area-tornado-y + width-tornado-y)] [die] ask patches with [pcolor = green and pxcor > area-tornado-x and pxcor < (area-tornado-x + width-tornado-x) and pycor > area-tornado-y and pycor < (area-tornado-y + width-tornado-y)] [set pcolor brown] ask patches with [pcolor = red and pxcor > area-tornado-x and pxcor < (area-tornado-x + width-tornado-x) and pycor > area-tornado-y and pycor < (area-tornado-y + width-tornado-y)] [set pcolor brown] end