red-queen-draft-humanreprobug
Model was written in NetLogo 6.0.4
•
Viewed 109 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
;;creating the breeds, i can know refer to them ;; associating an agent (resistance and soif) breed [humans human] breed [vampires vampire] humans-own [struggle? resistance hum-energy wall-turn-check breeding-random ] vampires-own [soif batenergy wall-turn-check pity ] to wall-draw ;; Use the mouse to draw buildings. if mouse-down? [ ask patch mouse-xcor mouse-ycor [ set pcolor grey ]] end to door-draw ;; Use the mouse to draw buildings. if mouse-down? [ ask patch mouse-xcor mouse-ycor [ set pcolor cyan ]] end to setup clear-all setup-patches set-default-shape humans "person" ; set color humans "blue" setup-individuals reset-ticks ;set vampires end to setup-patches ask patches [ set pcolor white ] ask n-of initial-food-patches patches [ set pcolor green ] end to setup-individuals create-humans initial-nb-humans [ set size 1 set resistance random-normal initial-resistance-mean 1 setxy random-xcor random-ycor set color blue set hum-energy hum-energy + 5 ] create-vampires initial-number-vampires [ set size 1 set soif random-normal initial-soif-mean 1 setxy random-xcor random-ycor set color red set batenergy batenergy + initial-vampires-energy ] end to go ifelse red-queen-model ; go command for red-queen model [ ask humans [eat-food ] ask vampires [ if any? humans-here [ hunt-humans?3 ] rt random-float 50 - random-float 50 fd 1 if [pcolor] of patch-ahead 1 = grey [wall] if [pcolor] of patch-ahead 1 = cyan [wall] set batenergy batenergy - 1 ] ask humans [ rt random-float 50 - random-float 50 fd 1 set hum-energy hum-energy - 1 if [pcolor] of patch-ahead 1 = grey [wall] if hum-energy > starvation-level[ if [pcolor] of patch-ahead 1 = cyan [wall]] set struggle? false ] ask humans [eat-food] ask humans [reproduce2] ask humans [check-death-humans] ask vampires [check-death-vampires] regrow-grass tick ] ;;go command for normal model [ ask humans [eat-food] ask vampires [ if any? humans-here [ hunt-humans? ] rt random-float 50 - random-float 50 fd 1 if [pcolor] of patch-ahead 1 = grey [wall] if [pcolor] of patch-ahead 1 = cyan [wall] set batenergy batenergy - 1 ] ask humans [ rt random-float 50 - random-float 50 fd 1 set hum-energy hum-energy - 1 ] ask humans [ if [pcolor] of patch-ahead 1 = grey [wall] if hum-energy > starvation-level[ if [pcolor] of patch-ahead 1 = cyan [wall]]] ask humans [eat-food] ask humans [reproduce] ask humans [check-death-humans] ask vampires [check-death-vampires] regrow-grass tick ] end to reproduce3 if random 1000 < 3 [ask humans [ hatch 1]] end to hunt-humans? set pity random 10 if pity < vampirification-probability [ask vampires [ if breed = vampires and count vampires < max-population [ask humans-on patch-here [set breed vampires set batenergy batenergy + 10] ask turtles-on patch-here [set color red]] ]] if pity > vampirification-probability [if any? humans-on patch-here [hunt-humans]] end to hunt-humans?3 set pity random 10 let hunted one-of humans-here let father vampires-here if hunted != nobody [ ask hunted [ set struggle? true ] ifelse soif > [ resistance ] of hunted ; si soif>resistance, lance le hunt-humans normal [ask vampires [ if pity < vampirification-probability [if breed = vampires [hatch 1 [ set soif random-normal [ soif ] of myself 1 ]]] if pity > vampirification-probability [if any? humans-on patch-here [hunt-humans]] ]] ; si soif[ask vampires [rt random-float 50 - random-float 50 fd 1 if [pcolor] of patch-ahead 1 = grey [wall] if [pcolor] of patch-ahead 1 = cyan [wall] set batenergy batenergy - 20 ]]] end to hunt-humans?2 set pity random 10 if pity < vampirification-probability [if any? humans-on patch-here [hunt-humans]] if pity > vampirification-probability [ hatch-vampires 1 [set batenergy batenergy + 20 ]] end to eat-food ask humans [ if pcolor = green [ set pcolor white set hum-energy hum-energy + 10 ] ifelse show-energy? [ set label hum-energy set label-color black] [ set label "" ] ] end to hunt-humans let hunted one-of (humans-here );with [not struggle?]) if hunted != nobody [ ; ask hunted [ set struggle? true ] ; ifelse soif > [ resistance ] of hunted ask hunted [ die ] set batenergy batenergy + 10 ] ; [ ; if soif != [ resistance ] of hunted [ die ] ; ] ;] end to create-vampires? create-vampires 1 [ set size 1 set soif random-normal initial-soif-mean 1 setxy random-xcor random-ycor set color red] end to reproduce set breeding-random random 10 ifelse breeding-random < breeding-probabilities [ask humans [ if breed = humans and count humans < max-population [if hum-energy > 50 [ set hum-energy hum-energy - 50 hatch 1 [ set hum-energy 50 ] ]]]] [ ask humans []] end to reproduce2 set breeding-random random 10 ifelse breeding-random < breeding-probabilities [ask humans [ if breed = humans and count humans < max-population [if hum-energy > 50 [ if breed = humans [ hatch 1 [ set resistance random-normal [ resistance ] of myself 1]] set hum-energy hum-energy - 50 hatch 1 [ set hum-energy 50 ] ]]]] [ ask humans []] end to check-death-humans ask humans [ if hum-energy <= 0 [ die ] ] end to check-death-vampires ask vampires [ if batenergy <= 0 [ die ] ] ifelse show-energy? [ set label batenergy ] [ set label "" ] end to regrow-grass ask patches with [pcolor = white] [ if random 1000 < food-regeneration [ set pcolor green ] ] end to wall ;; Turn agent away from wall set wall-turn-check random 10 if wall-turn-check >= 6 [wall-right-turn] if wall-turn-check <= 5 [wall-left-turn] end to wall-right-turn ;;Generate a random degree of turn for the wall sub-routine. rt 170 end to wall-left-turn ;;Generate a random degree of turn for the wall sub-routine. lt 170 end to-report average-batenergy ifelse count vampires > 0 [ report mean [ batenergy ] of vampires ] [ report 0 ] end to-report average-hum-energy ifelse count humans > 0 [ report mean [ hum-energy ] of humans ] [ report 0 ] end to-report average-soif ifelse count vampires > 0 [ report mean [ soif ] of vampires ] [ report 0 ] end to-report average-resistance ifelse count humans > 0 [ report mean [ resistance ] of humans ] [ report 0 ] end
There is only one version of this model, created about 6 years ago by noe rehspringer.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
red-queen-draft-humanreprobug.png | preview | Preview for 'red-queen-draft-humanreprobug' | about 6 years ago, by noe rehspringer | Download |
This model does not have any ancestors.
This model does not have any descendants.