Child of vampires

No preview image

1 collaborator

Default-person noe rehspringer (Author)

Tags

(This model has yet to be categorized with any tags)
Child of model vampires preview imagevampires Parent of 1 model: Child of Child of vampires
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.4 • Viewed 30 times • Downloaded 0 times • Run 0 times
Download the 'Child of vampires' 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]
humans-own [struggle?
  resistance
  hum-energy
wall-turn-check
  breeding-random
]
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
  ifelse humans-food-mortality-model?
  [ask patches [ set pcolor black ]
   ask n-of initial-food-patches patches [ set pcolor green
  ]]
  [ask patches [ set pcolor black ]]
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
    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 bat-energy bat-energy + 50
    set color red]
end 

to go
  ifelse humans-food-mortality-model? [

  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
]

  ask humans [ eat-food]
  ask humans [reproduce]
  ask humans [check-death-humans]
  ask vampires [check-death-vampires]
  regrow-grass

 tick
  ]
  [
  ask vampires [
    rt random-float 50 - random-float 50
    fd 1
    set bat-energy bat-energy - 1
    if any? humans-here
    [ hunt-humans?]

    ; if [pcolor] of patch-ahead 1 != grey
    ; [wall]
  ]

  ask humans [
  rt random-float 50 - random-float 50
   fd 1

]


  ask humans [reproduce2]

  ask vampires [check-death-vampires]


 tick
  ]
end 

to hunt-humans?
set pity random 10
  ;ifelse pity < vampirification-probability

 ; [ if any? humans-on patch-here [hunt-humans]]
;  [if any? humans-on patch-here
  ;  [ hatch-vampires 1
    ; [set bat-energy bat-energy + 10
;  ]]]
  if pity < vampirification-probability
  [if any? humans-on patch-here [hunt-humans]]

  if pity > vampirification-probability
  [ hatch-vampires 1
     [set bat-energy bat-energy + 50
  ]]
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 red]
   [ 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
  set breeding-random random 10
  ifelse breeding-random < breeding-probabilities
  [ask humans [
    if hum-energy > 50 [
      set hum-energy hum-energy - 50
      hatch 1 [ set hum-energy 50 ]
    ]]]
    [  ask humans [ rt random-float 50 - random-float 50
   fd 1
      set hum-energy hum-energy - 1]]
end 

to reproduce2
  set breeding-random random 10
  ifelse breeding-random < breeding-probabilities
  [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-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 3 months ago by noe rehspringer.

Attached files

No files