vampires
Model was written in NetLogo 6.0.4
•
Viewed 112 times
•
Downloaded 11 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 ] vampires-own [soif bat-energy wall-turn-check pity ] to building-draw ;; Use the mouse to draw buildings. if mouse-down? [ ask patch mouse-xcor mouse-ycor [ set pcolor grey ]] 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 black ] 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 white set struggle? false ] create-vampires initial-number-vampires [ set size 1 set soif random-normal initial-soif-mean 1 setxy random-xcor random-ycor set bat-energy bat-energy + 100 set color red] end to go ask humans [eat-food] ask vampires [ rt random-float 50 - random-float 50 fd 1 set bat-energy bat-energy - 1 if any? humans-here [ hunt-humans? ; hunt-humans ] if [pcolor] of patch-ahead 1 != black [wall] ] ask humans [ rt random-float 50 - random-float 50 fd 1 set hum-energy hum-energy - 1 ] eat-food reproduce ask humans [check-death-humans] ask vampires [check-death-vampires] regrow-grass tick end to hunt-humans? set pity random 10 ifelse pity < 2 [ if any? humans-on patch-here [hunt-humans]] [if any? humans-on patch-here [ hatch-vampires 1 [set bat-energy bat-energy + 5 ]]] end to eat-food ask humans [ if pcolor = green [ set pcolor black set hum-energy hum-energy + 10 ] ifelse show-energy? [ set label hum-energy set label-color blue] [ 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 bat-energy bat-energy + 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 ask humans [ if hum-energy > 50 [ set hum-energy hum-energy - 50 hatch 1 [ set hum-energy 50 ] ] ] end to check-death-humans ask humans [ if hum-energy <= 0 [ die ] ] end to check-death-vampires ask vampires [ if bat-energy <= 0 [ die ] ] ifelse show-energy? [ set label bat-energy ] [ set label "" ] end to regrow-grass ask patches with [pcolor = black] [ if random 100 < 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
There is only one version of this model, created about 6 years ago by noe rehspringer.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
vampires.png | preview | Preview for 'vampires' | about 6 years ago, by noe rehspringer | Download |