final-vampire-model

final-vampire-model preview image

1 collaborator

Default-person noe rehspringer (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.4 • Viewed 82 times • Downloaded 8 times • Run 0 times
Download the 'final-vampire-model' modelDownload this modelEmbed this model

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]
breed [immunes immune]
humans-own [struggle?
  resistance
  hum-energy
wall-turn-check
  breeding-random
]
immunes-own  [imenergy
  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-default-shape immunes "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 - (initial-nb-humans * (initial-prop-immunes / 100))
   [ 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
  ]
    create-immunes   initial-nb-humans * (initial-prop-immunes / 100)
  [ set size 1
     setxy random-xcor random-ycor
    set color magenta
  set imenergy imenergy + 10
  ]
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 = magenta
     [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 = magenta
          [wall]]
    set struggle? false
    ]
  ask humans [eat-food]
  ask humans [reproduce]
  ask humans [check-death-humans]
  ask vampires [check-death-vampires]
  regrow-grass

 tick
  ]

  ;;go command for normal model
  [



  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]

if mortal-vampires = true [ ask vampires [check-death-vampires]]



  ask immunes [
   rt random-float 50 - random-float 50
   fd 1
   set imenergy imenergy - 1
   if [pcolor] of patch-ahead 1 = grey
               [wall]
   if imenergy > starvation-level[ if [pcolor] of patch-ahead 1 = cyan
                [wall]]
   set imenergy imenergy - 1
   eat-food2
   reproduce4
   check-death-immunes]


    ask humans [eat-food

                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]]
                eat-food
                reproduce
                 check-death-humans]

     ask immunes [reproduce4]

regrow-grass
 tick
  ]
end 

to reproduce3
  if random 1000 < 3 [ask humans [

        hatch 1]]
end 

to hunt-humans?
set pity random 100
  if pity < vampirification-probability
  [ask vampires [
    if breed = vampires and count vampires < max-population  [let hunted one-of (humans-here )
                                                             if hunted != nobody [ask hunted [
        set breed vampires
        set batenergy batenergy + initial-vampires-energy
      set color red]]


      ;ask humans-on patch-here [die]
    ;hatch-vampires 1 [set color red
        ;set batenergy batenergy + initial-vampires-energy]
    ]
  ]]
  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
  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
                             [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]]
    ]]
    ; 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 = magenta
     [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 eat-food2
 ask immunes [
    if pcolor = green [
      set pcolor white
      set imenergy imenergy + 10
    ]
 ifelse show-energy?
      [ set label imenergy  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 100
  ifelse breeding-random < breeding-probabilities
  [ifelse immunes-random-occurence < random 1000  [ask humans [
      if breed = humans and (count humans +  count immunes ) < max-population
    [if hum-energy > 50 [
      set hum-energy hum-energy - 50
      hatch 1 [ set hum-energy 50 ]
  ]]]]
    [ask humans [
      if breed = humans and (count humans +  count immunes ) < max-population
    [if hum-energy > 50 [
      set hum-energy hum-energy - 50
      hatch-immunes 1 [ set imenergy 50
        set color magenta]
  ]]]]
  ]
    [  ask humans []]
end 

to reproduce4
  set breeding-random random 10
  ifelse breeding-random < breeding-probabilities
  [ifelse immunes-random-occurence < random 1000  [ask immunes [
      if breed = immunes and (count humans +  count immunes ) < max-population
    [if imenergy > 50 [
      set imenergy imenergy - 50
      hatch-humans 1 [ set hum-energy 50
      set color blue]
  ]]]]
    [ask humans [
      if breed = immunes and (count humans +  count immunes ) < max-population
    [if imenergy > 50 [
      set imenergy imenergy - 50
      hatch-immunes 1 [ set imenergy 50
        set color magenta]
  ]]]]
  ]
    [  ask immunes []]
end 

to reproduce2
 ask turtles [
    if breed = humans and count humans < max-population  and random 100 < 3 [ask humans [

      hatch 1]
      ;set breeding-random random 1000
  ;ifelse breeding-random < 5
 ; [ask humans [

     ; hatch 1 [ set hum-energy 50 ]
  ;  ]]
   ; [  ask humans [ rt random-float 50 - random-float 50
  ; fd 1
      ]]
end 

to check-death-humans
  ask humans [
   if hum-energy <= 0 [ die ]
  ]
end 

to check-death-immunes
  ask immunes [
   if imenergy <= 0 [ die ]
  ]
end 

to check-death-vampires
  ask vampires [
   if batenergy <= 0 [ die ]
  ]
   ifelse show-energy?
      [ set label batenergy set label-color black]
   [ 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 

to-report average-imenergy
  ifelse count immunes > 0
    [ report mean [ imenergy ] of immunes ]
    [ report 0 ]
end 

There is only one version of this model, created over 5 years ago by noe rehspringer.

Attached files

File Type Description Last updated
final-vampire-model.png preview Preview for 'final-vampire-model' over 5 years ago, by noe rehspringer Download

This model does not have any ancestors.

This model does not have any descendants.