Sugarscape Seasonal Migration
Model was written in NetLogo 6.1.1
•
Viewed 399 times
•
Downloaded 46 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Click to Run Model
extensions [matrix] globals [ gini-index-reserve lorenz-points winter? ;;variable para el invierno duraciontotal ;; duracion del invierno ] ;; posibles agregados: enfermedades contagiosas, prediposición a enfermarse tomando en cuenta un metabolismo que no es satisfecha ;; ECT diabetes, prediabetes, normal -> tortugas profesionales de la salud; distribución de recursos y herencia ;; azucar limitar los recursos; azucar contaminada ;; accidentes; azucar se contamine siempre y cuando haya muchas tortugas alrededor ;; cuando la tortuga consume azucar genera deshecho turtles-own [ sugar ;; the amount of sugar this turtle has metabolism ;; the amount of sugar that each turtles loses each tick vision ;; the distance that this turtle can see in the horizontal and vertical directions vision-points ;; the points that this turtle can see in relative to it's current position (based on vision) age ;; the current age of this turtle (in ticks) max-age ;; the age at which this turtle will die of natural causes ] patches-own [ psugar ;; the amount of sugar on this patch max-psugar ;; the maximum amount of sugar that can be on this patch ] ;; ;; Setup Procedures ;; to setup if maximum-sugar-endowment <= minimum-sugar-endowment [ user-message "Oops: the maximum-sugar-endowment must be larger than the minimum-sugar-endowment" stop ] clear-all create-turtles initial-population [ turtle-setup ] setup-patches update-lorenz-and-gini set winter? true ;;indica si es true que hay invierno en el hemisferio norte (y verano en el sur) set duraciontotal 40 ;;indica cuantos ticks dura el invierno/verano reset-ticks end to turtle-setup ;; turtle procedure set color red set shape "turtle" ;move-to one-of patches with [not any? other turtles-here] set sugar random-in-range minimum-sugar-endowment maximum-sugar-endowment set metabolism random-in-range 1 4 set max-age random-in-range 60 100 set age 0 set vision random-in-range 1 10 ;; turtles can look horizontally and vertically up to vision patches ;; but cannot look diagonally at all set vision-points [] foreach (range 1 (vision + 1)) [ n -> set vision-points sentence vision-points (list (list 0 n) (list n 0) (list 0 (- n)) (list (- n) 0)) ] move-to one-of patches with [(pxcor < 15 and pyc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 0 0 0 0 0 0 0 0]] let i 0 let j 0 ;let m1 matrix:transpose m ;; let row-i matrix:get-row m i ask patches with [pxcor = i and pycor = j] ;[set max-psugar item rowx row-i let rowx 49 repeat 50 [ repeat 50 [let row-i matrix:get-row m i ask patches with [pxcor = i and pycor = j] [set max-psugar item rowx row-i ;ask patches with [pxcor = i and pycor = j] [set max-psugar item rowx (matrix:get-row m i) set psugar max-psugar patch-recolor ] set rowx rowx - 1 set j j + 1 ] set i i + 1 set j 0 set rowx 49] ;ask patches [patch-recolor] ;file-open "sugar-map.txt" ;foreach sort patches [ p -> ; ask p [ ; set max-psugar file-read ; set psugar max-psugar ; patch-recolor ; ] ;] ;file-close end ;; ;; Runtime Procedures ;; to go if not any? turtles [ stop ] ask patches [ ;pregunto si hay invierno ifelse (estaciones? = true) [ ifelse (winter? = true) [ifelse (pxcor + 48 = pycor * -1) or (pxcor * -1 + 48 = pycor) and (pxcor > pycor * -1 + 48) or (pxcor * -1 + 48 > pycor) [patch-growbackwinter] [patch-growback] ] [ifelse (pxcor + 48 = pycor * -1) or (pxcor * -1 + 48 = pycor) and (pxcor > pycor * -1 + 48) or (pxcor * -1 + 48 > pycor) [patch-growback] [patch-growbackwinter] ] ] [patch-growbacknormal ] patch-recolor ] ask turtles [ turtle-move turtle-eat set age (age + 1) if sugar <= 0 ;or age > max-age [ ;hatch 1 [ turtle-setup ] die ] run visualization ] update-lorenz-and-gini ;;invierno y verano if (ticks mod duraciontotal = 0) [ifelse (winter? = true) [set winter? false] [set winter? true] ] tick end to turtle-move ;; turtle procedure ;; consider moving to unoccupied patches in our vision, as well as staying at the current patch let move-candidates (patch-set patch-here (patches at-points vision-points) with [not any? turtles-here]) let possible-winners move-candidates with-max [psugar] if any? possible-winners [ ;; if there are any such patches move to one of the patches that is closest move-to min-one-of possible-winners [distance myself] ] end to turtle-eat ;; turtle procedure ;; metabolize some sugar, and eat all the sugar on the current patch set sugar (sugar - metabolism + psugar) set psugar 0 end to patch-recolor ;; patch procedure ;; color patches based on the amount of sugar they have if psugar < 0 [set psugar 0] set pcolor (yellow + 4.9 - psugar) end to patch-growbacknormal ;; patch procedure ;; gradually grow back all of the sugar for the patch, en el original decía 1 en vez de 0.5 set psugar min (list max-psugar (psugar + 0.5)) end to patch-growback ;; patch procedure ;; gradually grow back all of the sugar for the patch set psugar min (list max-psugar (psugar + 1)) end ;;agrego crecimiento invernal to patch-growbackwinter ;; patch procedure ;; gradually grow back all of the sugar for the patch set psugar min (list max-psugar (psugar + (1 / 8))) end to update-lorenz-and-gini let num-people count turtles let sorted-wealths sort [sugar] of turtles let total-wealth sum sorted-wealths let wealth-sum-so-far 0 let index 0 set gini-index-reserve 0 set lorenz-points [] repeat num-people [ set wealth-sum-so-far (wealth-sum-so-far + item index sorted-wealths) set lorenz-points lput ((wealth-sum-so-far / total-wealth) * 100) lorenz-points set index (index + 1) set gini-index-reserve gini-index-reserve + (index / num-people) - (wealth-sum-so-far / total-wealth) ] end ;; ;; Utilities ;; to-report random-in-range [low high] report low + random (high - low + 1) end ;; ;; Visualization Procedures ;; to no-visualization ;; turtle procedure set color red end to color-agents-by-vision ;; turtle procedure set color red - (vision - 3.5) end to color-agents-by-metabolism ;; turtle procedure set color red + (metabolism - 2.5) end ; Copyright 2009 Uri Wilensky. ; See Info tab for full copyright and license.
There are 5 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Sugarscape Seasonal Migration.png | preview | Preview for 'Sugarscape Seasonal Migration' | almost 2 years ago, by Diego Díaz Córdova | Download |
Diego Díaz Córdova
error in modelin commons not in netlogo desktop
when I run this model in netlogo desktop, it all fine, but here in modelingcommons it launchs an error "ITEM expected this input to be a string or list, but got a number instead", I don't understand if it is modelingcommons' problem or something is wrong with the code (but in desktop it runs with any problem)
Posted almost 2 years ago
Hendra Kusumah
Maybe it's a bug, try this.. (Question)
let row-i matrix:get-row m i ask patches with [pxcor = i and pycor = j] [set max-psugar item rowx row-i
Posted almost 2 years ago
Diego Díaz Córdova
you're right!!!
you are a genious!!! thank you so so so so much!!! now it works!!! thank you Hendra!
Posted almost 2 years ago