Peter Hate Club

Peter Hate Club preview image

1 collaborator

Default-person semi-complete 7 (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 7.0.0 • Viewed 3 times • Downloaded 0 times • Run 0 times
Download the 'Peter Hate Club' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

(a general understanding of what the model is trying to show or explain)

HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

THINGS TO NOTICE

(suggested things for the user to notice while running the model)

THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

CREDITS AND REFERENCES

(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;; changes since last version:
;; depopulate suburban hell and communicate our autumnul energy
;; add peters house
;; started adding comfort zone

globals [total-victims
  center-x    ; x-coordinate of the park circle's center
  center-y    ; y-coordinate of the park circle's center
  circle-radius ; radius of the park circle in patch units]
  peters-house-x
  peters-house-y
  radius ; radius of anti-comfort zone
  cradius ; radius of comfort zone 
  kill-log ; List to store kill events 
  death-count
]

turtles-own [
  kill-chance 
  victim-type 
  is-dead?
  wander-type
  sense-range
  target-victim
  time-dead
]

To setup
  clear-all 
  set center-x 50
  set center-y 25
  set circle-radius 10
  set radius 7 ; anti-comfort zone radius
  set cradius 33 ; comfort zone radius 
  setup-world
  create-victims
  create-peter
  reset-ticks
  set kill-log []
end 

to setup-world
  resize-world 0 100 0 50
  ask patches [ set pcolor white ]
  
    ask patches with [(19 < pycor and pycor < 31) AND (91 <= pxcor and pxcor <= 99)] 
  [
    set pcolor brown
  ]
    ask patches with [(19 < pycor and pycor < 31) AND (79 <= pxcor and pxcor <= 87)]
  [
    set pcolor brown
  ]
    ask patches with [(19 < pycor and pycor < 31) AND (1 <= pxcor and pxcor <= 9)] 
  [ 
    set pcolor brown
  ] 
      ask patches with [(19 < pycor and pycor < 31) AND (13 <= pxcor and pxcor <= 21)] 
  [ 
    set pcolor brown
  ]
  
     ask patches with [(19 < pycor and pycor < 31) AND (25 <= pxcor and pxcor <= 33)] 
  [
    set pcolor brown
  ]
     ask patches with [(19 < pycor and pycor < 31) AND (67 <= pxcor and pxcor <= 75)] 
  [
    set pcolor brown
  ]
     ask patches with [(1 < pycor and pycor < 13) AND (61 <= pxcor and pxcor <= 72)] 
  [
    set pcolor brown
  ]
     ask patches with [(1 < pycor and pycor < 13) AND (28 <= pxcor and pxcor <= 39)] 
  [
    set pcolor brown
  ]
     ask patches with [(1 < pycor and pycor < 13) AND (43 <= pxcor and pxcor <= 57)] 
  [
    set pcolor brown
      ]
     ask patches with [(37 < pycor and pycor < 49) AND (43 <= pxcor and pxcor <= 57)] 
  [
    set pcolor brown
  ]
    ask patches with [(35 < pycor and pycor < 50) AND (0 < pxcor and pxcor < 20)] [
    set pcolor orange
  ]
    ask patches with [(35 < pycor and pycor < 50) AND (80 < pxcor and pxcor < 100)] [
    set pcolor magenta
  ]
  
    ask patches with [(40 < pycor and pycor < 50) AND (60 < pxcor and pxcor < 78)] [
    set pcolor pink
  ]
  
    ask patches with [(40 < pycor and pycor < 50) AND (22 < pxcor and pxcor < 40)] [
    set pcolor violet
  ]
    ask patches with [(0 < pycor and pycor < 15) AND (0 < pxcor and pxcor < 25)] [
    set pcolor pink 
  ]
  
  ask patches with [(0 < pycor and pycor < 15) AND (75 < pxcor and pxcor < 100)] [
    set pcolor pink 
  ]
  
    ask patches with [pcolor = brown and (pxcor mod 3 + 1 = 3)  and (pycor mod 3 = 0)] [ ; suburban hell mcmansions
      sprout 1 [
        set shape "house"
        set size 4
        stamp
      ]
  ]
  
   create-turtles 1 [ ; park grass
    set shape "circle"
    set color [0 128 0]
    set size (circle-radius * 2) + 0.5 ; Set size to be 2x the radius, with a little buffer
    setxy center-x center-y
    stamp
    die
  ]
  
  ask patches with [pxcor = center-x and pycor = center-y] [ ; park tree
    sprout 1 [
      set shape "tree"
      set size 12
      set color orange
      stamp
    ]
  ]
end 

to create-victims
  clear-turtles
   set total-victims victims 
  
  ask n-of total-victims patches with [pcolor = white] [
    sprout 1 [
      set color green
      set shape "person" 
      set size 1.5 
      set victim-type (random 3 ) ; victim-type-threshold now does literally nothing!!
      set wander-type victim-type
      set is-dead? false
      set sense-range 5
      set time-dead 0
      
  ]]
end 

to create-peter 
  create-turtles 1[
    set color blue 
    set size 3
    set shape "person"
    set kill-chance howbaddoeshewantit
    set target-victim nobody
    ask patches with [pcolor = brown and (pxcor mod 3 + 1 = 3)  and (pycor mod 3 = 0)] [ ; where peter lives, and center of the comfort zone
      set peters-house-x pxcor                                                           ; in a just world this condition only results in one patch being true
      set peters-house-y pycor
    ]
    setxy peters-house-x peters-house-y
  ]
      ask patches with [abs(distancexy peters-house-x peters-house-y - cradius) < .5][ ; anti-comfort zone (donut hole)
      set pcolor red
  ]
   ask patches with [abs(distancexy peters-house-x peters-house-y - radius) < .5][ ; anti-comfort zone (donut hole)
      set pcolor sky
  ]
end 

;; added rule that makes victims who are dead not move. 

to go 
  if should-stop? [stop]
  tick 
  ask turtles with [color = red AND is-dead? = true] [
    set time-dead (time-dead + 1)
  ]
  ask turtles with [color = red][
    fd 0 ;; could this be stop? 
  ]
  ask turtles with [color = yellow][
    fd 0 ;; could this be stop?
  ]
  ask turtles with [color = blue] [
    rt random 70 - random 70 
    fd random 2
  
    ask turtles with [wander-type = 0 AND is-dead? = false] [ ; regular-victim: brown-magenta-green-pink
      wander-type0 
    ]
    ask turtles with [wander-type = 1 AND is-dead? = false] [ ; mo-victim: brown-pink
      wander-type1
    ]
    ask turtles with [wander-type = 2 AND is-dead? = false] [ ; kids-victim: brown-orange-green
      wander-type2
    ]
    ask turtles with [wander-type = 3 AND is-dead? = false] [ ; police-victim: brown-violet-pink
      wander-type3 
    ]
    ask turtles with [wander-type = 42 AND is-dead? = false ][ ;panic mode 
      panic-mode 
    ]
    ask turtles with [color = red AND is-dead? = true][ ;police-tape = bodies turn yellow 
      police-tape
    ]
    stalk 
    sense-death
  ]
  
  wait tick-delay
end  

to-report should-stop?
  report count turtles with [is-dead? = true] >= 10
end 

to stalk
ask turtles with [color = blue AND shape = "person"][
  ;; If Peter doesn't have a target or target is dead/ too far, find a new one
  if target-victim = nobody or [is-dead?] of target-victim or distance target-victim > 10 [
    let potential-victims other turtles with [color = green and shape = "person" and not is-dead? and victim-type = 1 ] in-radius 30
    ifelse any? potential-victims [
      set target-victim one-of potential-victims]
    [
      set target-victim nobody]
  ]


  ;; If Peter has a target, follow it
  if target-victim != nobody and is-turtle? target-victim [ ;and target-victim != 0
    face target-victim
  
    ;; Move toward target, but not too close (maintain stalking distance)
    let dist distance target-victim
    if dist  > 4 [
      fd 1
    ]
  
    ;; Check if victim is isolated (away from other victims)
    let nearby-victims other turtles with [color = green and is-dead? = false] in-radius 4
      if count nearby-victims = 1 and member? target-victim nearby-victims and [pcolor] of patch-here = white[
      ;; Victim is alone! Time to strike
        kill-victim target-victim
        set target-victim nobody
    ]
  ]
]
end 

   

;; improved kill logic that turns victims red instead of patches

to kill-victim [victim]
  
  let d distancexy peters-house-x peters-house-y
  
  if random-float 1.0 < kill-chance AND any? turtles-here with [color = green AND pcolor = white and shape = "person" AND (d >= radius and d <= cradius)][ 
    ask victim [
      set color red 
      set is-dead? true
      
      set kill-log lput (list ticks xcor ycor) kill-log
    ]
  ]
end  

to wander-type0 ; regular-victim: brown-magenta-green-pink
  if random-float 100 < 25 [
    let target-patch nobody 
    (ifelse
    (ticks mod 960 < 240) [set target-patch one-of patches with [pcolor = brown] 
      ]
    (ticks mod 960 < 480) [set target-patch one-of patches with [pcolor = magenta] 
      ]
    (ticks mod 960 < 720) [set target-patch one-of patches with [pcolor = green] 
      ]
    [set target-patch one-of patches with [pcolor = pink] 
      ]
)
    if target-patch != nobody [
      face target-patch
      stop
    ]
  ]
  
  rt random 90 - random 90
  fd 1 
end 

to-report kill-locations
  report kill-log
end  

to wander-type1 ; mo-victim: brown-pink
  if random-float 100 < 25 [
    let target-patch nobody 
    (ifelse
      (ticks mod 960 < 480) [set target-patch one-of patches with [pcolor = brown] 
      stop]
    [set target-patch one-of patches with [pcolor = pink] 
      stop]
    )
    if target-patch != nobody [
      face target-patch
      stop
    ]
  ]
  rt random 90 - random 90
  fd 1 
end 

to wander-type2 ; kids-victim: brown-orange-green
  if random-float 100 < 25 [
    let target-patch nobody 
    (ifelse
    (ticks mod 960 < 320) [set target-patch one-of patches with [pcolor = brown] 
      stop]
    (ticks mod 960 < 640) [set target-patch one-of patches with [pcolor = orange] 
      stop]
    [set target-patch one-of patches with [pcolor = green] 
      stop]
)
    if target-patch != nobody [
      face target-patch
      stop
    ]
  ]
  rt random 90 - random 90
  fd 1 
end 

to wander-type3 ; police-victim: brown-violet-pink
  if random-float 100 < 25 [
    let target-patch nobody 
    (ifelse
    (ticks mod 960 < 320) [set target-patch one-of patches with [pcolor = brown] 
      stop]
    (ticks mod 960 < 640) [set target-patch one-of patches with [pcolor = violet] 
      stop]
    [set target-patch one-of patches with [pcolor = pink] 
      stop]
)
    if target-patch != nobody [
      face target-patch
      stop
    ]
  ]
  rt random 90 - random 90
  fd 1 
end 

to sense-death 
  ask turtles with [color = green and is-dead? != true][
    if any? other turtles with [color = red] in-radius sense-range[
      ask one-of turtles-here with [color = green and patch-here != violet][
      set wander-type 42]
    ]
  ]
end  

;; Panic mode - move victims towards a 'safe zone' 

to panic-mode 
  set color orange 
  ask turtles-here with [color != blue and is-dead? != true][
    let p patch-here 
    ifelse [pcolor] of p != violet [ 
      face one-of patches with [pcolor = violet ]
      rt random 90 - random 90 
      fd 1 ] 
    [
      set color green 
      set wander-type victim-type 
    ]
  ]
end  

;Police Tape - turns dead victims yellow 

to police-tape 
  ifelse time-dead < (960 / 2) [
  ]
  [set color yellow]
end  





  

There is only one version of this model, created about 7 hours ago by semi-complete 7.

Attached files

File Type Description Last updated
Peter Hate Club.png preview Preview for 'Peter Hate Club' about 7 hours ago, by semi-complete 7 Download

This model does not have any ancestors.

This model does not have any descendants.