BehaviorSpace version

No preview image

1 collaborator

Default-person Kevin Jin (Author)


(This model has yet to be categorized with any tags)
Child of model Terror Paranoia preview imageTerror Paranoia
Model group MAM-2015 | Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.2.0 • Viewed 255 times • Downloaded 19 times • Run 0 times
Download the 'BehaviorSpace version' modelDownload this modelEmbed this model

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

Info tab cannot be displayed because of an encoding error

Comments and Questions

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

Click to Run Model

breed [people person]
globals [
  mouse-was-down?   ;;tracks the previous state of the mouse
  terror-event?     ;;tracks whether a terror event has occurred recently, true after a terror event until community intervention occurs
  help-timer        ;;keeps track of time until community intervention occurs
turtles-own [
  fear-level           ;;level of fear of each turtle
  group                ;;which group each turtle is in
  last-patch-residual  ;;keeps track of the last patch's residual fear level so fear does not constantly increase while in area
patches-own [residual-fear] ;;residual fear from after terror events

;Setup Procedure
;Clears everything and then initializes the variables. Initial FEAR-LEVEL is randommly assigned and 
;the group is based on each turtle's WHO and how many groups there should be.
;The ask people call is necessary after the create-people command block because not all the 
;people have been assigned to a group yet and so there would be no links created for the first 
;few turtles. Initialize the global variables and patch variables as well.

to setup 
  set-default-shape people "person"
  create-people population [
    set size 1.5
    setxy random-xcor random-ycor
    set fear-level random 100 + 1
    set group who mod groups  
  ask people [
    if network?
    [ let network n-of links-with-others other people with [group = [group] of myself]
      create-links-with network] 
  ask patches [
    set residual-fear 0
    if show-residual-fear? = true
    [set plabel residual-fear]
  set mouse-was-down? false
  set terror-event? false
  set help-timer 0
  set average-fear 0
  set once? false

;Go Procedure
;The go procedure checks if a terror event has occurred. Then it asks the people
;to adjust their FEAR-LEVEL based on the person they physically encounter and if
;this is a network, adjust their FEAR-LEVEL based on the network.
;Then adjust the FEAR-LEVEL based on whether there is any RESIDUAL-FEAR left on the 
;patch. Update the color and the LAST-PATCH-RESIDUAL to the RESIDUAL-FEAR of the current 
;patch. Then move. Then check the patches to see if they should be showing the residual fear
;and then decay any RESIDUAL-FEAR by the RESIDUAL-DECAY-RATE. Then finally check if 
;there is a community intervention on this turn.

to go
  ask people [
    let other-person-here one-of other people-here
    if other-person-here != nobody
    [ adjust-fear-levels other-person-here ]
    if network? = true and ticks mod network-communication-frequency = 0 ;adjust FEAR-LEVEL based on every link neighboor
    [ foreach [self] of link-neighbors [ adjust-fear-levels ? ] ]
    set last-patch-residual [residual-fear] of patch-here
  ask patches [
    ifelse show-residual-fear? = true
    [ set plabel residual-fear ]
    [ set plabel "" ]
    if residual-fear > 0
    [ set residual-fear (residual-fear - residual-decay-rate) ] 
  ifelse help-timer > 0
  [ set help-timer help-timer - 1 ]
    if terror-event? = true
      set terror-event? false 
      ask n-of number-of-interventions people
      [ set fear-level round ((1 - level-of-intervention) * fear-level) ] 
  if ticks mod 1500 = 1
  [ifelse mean [fear-level] of people = average-fear
    [ifelse once? = false
      [ set average-fear-before average-fear
        set once? true]
      [set average-fear-after average-fear
        show average-fear-after
    [set average-fear mean [fear-level] of people]]

;terror-event procedure
;Checks to see if the mouse is currently not down and was previously down. This is done 
;so that the only a single click is registered, instead of registering the entire time that the mouse
;is down. If a click is detected, everyone within the radius is increase their FEAR-LEVEL
;by the TERROR-SEVERITY. Set the residual fear for the surrounding patches and then start HELP-TIMER
;whcih keeps track of when community intervention occurs. TERROR-EVENT? is then updated 
;as is the current status of the mouse.

to terror-event
    ask patch 0 0 [
      ask people in-radius terror-radius [
       let boundary fear-level + terror-severity < 100
       ifelse boundary
       [ set fear-level (fear-level + terror-severity) ]
       [ set fear-level 100 ]
       set last-patch-residual fear-level
      ask patches in-radius terror-radius
      [ set residual-fear round (terror-severity * initial-residual-fear / 100) ]   
    if terror-event? = false
    [set help-timer intervention-delay]
    set terror-event? true

;adjust-fear-levels, a turtle procedure
;The FEAR-LEVELs of the people are adjusted based on what the the FEAR-LEVEL of the
;other-turtle argument. To do this, it takes 5% of the difference in FEAR-LEVELs 
;(whether positive or negative) and adds it to its own FEAR-LEVEL. 

to adjust-fear-levels [other-turtle]
  if other-turtle != nobody
    let difference round ([fear-level] of other-turtle - fear-level) / 20
    let fear-change round (fear-level + difference)
    ifelse terror-event? = false
      ifelse fear-change < 0 
      [ set fear-level 0 ]
        ifelse fear-change > 100
        [ set fear-level 100 ]
        [ set fear-level fear-change ]
      if difference > 0
        ifelse fear-change > 100
          [ set fear-level 100 ]
          [ set fear-level fear-change ]

;residual-fear-effect, a turtle procedure
;Increases the FEAR-LEVEL by the current RESIDUAL-FEAR of the patch the turtle is on

to residual-fear-effect
  if [residual-fear] of patch-here != 0 and last-patch-residual = 0
    let pdifference fear-level + [residual-fear] of patch-here
    ifelse pdifference > 100
    [ set fear-level 100 ]
    [ set fear-level pdifference ]

;move, a turtle procedure
;If there is a person ahead and a random number is less than the fear-level, 
;then go towards them, otherwise turn randomly and then advance forward.

to move
  let person-ahead one-of people in-cone 2 120
  ifelse person-ahead != nobody and (random 100 + 1) < fear-level
  [ face person-ahead ]
  [ rt random 121 - 60 ]
  fd 1

;update-color, a turtle procedure
;updates COLOR of turtle, lower FEAR-LEVEL is more blue and higher FEAR-LEVEL
;is more red.

to update-color
  ifelse fear-level = 50
  [ set color white ]
    ifelse fear-level > 50
    [ set color 18 - ((fear-level - 50) / 10) ]
    [ set color 108 - ((50 - fear-level) / 10) ]

There is only one version of this model, created almost 9 years ago by Kevin Jin.

Attached files

No files

Parent: Terror Paranoia

This model does not have any descendants.

Graph of models related to 'BehaviorSpace version'