Superstition

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Model group MAM-2016 | Visible to everyone | Changeable by the author
Model was written in NetLogo 6.0-M5 • Viewed 207 times • Downloaded 9 times • Run 0 times
Download the 'Superstition' 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 [cats cat]
breed [humans human]

globals [number-superstitous probability-list number-of-switches human-influence-range belief-influence]
humans-own [alpha superstitious? red-count cat-sighting-memory introduced?]

to setup
  clear-all
  reset-ticks
  set human-influence-range 5
  set number-of-switches 0
  set belief-influence 24
  set-default-shape humans "person"
  set-default-shape cats "wolf"
  setup-consideration-math
  create-cats number-of-cats
  [
    set color gray
    setxy random-xcor random-ycor
  ]
  create-humans 75
  [
    set color blue
    set introduced? false
    set cat-sighting-memory n-values memory-length [0] ;; Start by remembering no red patches under cats
    setxy random-xcor random-ycor
    set alpha random-normal initial-average-alpha 5
    set superstitious? false
    set red-count 1 ;; Avoids starting out with unrealistic probabilities, defaults to .33 or .66 for red-probability
  ]
end 

to go
  color-patches
  ask cats [
    cat-wiggle
  ]
  ask humans [
    wiggle
    adjust-alpha
    look
  ]
  tick

  ;set c c + count patches with [pcolor = red and any? cats-here] / count patches with [pcolor = red]
  ;set true-p c / ticks
  ;;set avg-alpha (sum [alpha] of n-of 20 humans) / 20

  set number-superstitous count humans with [superstitious?]
end 

to cat-wiggle ;;cat procedure
   ;;cats move more slowly than humans, so that humans probably don't see the same cat twice
  rt 30
  lt 30
  fd .1
end 

to color-patches
  if ticks mod 50 = 0 [
    ask patches [
      ifelse random 100 < red-patch-percentage
      [set pcolor red]
      [set pcolor black]
    ]
  ]
end 

to adjust-alpha ; human procedure
  if any? humans in-radius human-influence-range with [superstitious?]
  [
    set alpha alpha + other-human-influence
    set introduced? true
  ]
  if introduced? and not any? humans in-radius human-influence-range with [superstitious?]
  [
    set alpha alpha - other-human-influence / superstition-influence-bias
  ]

  if alpha < 0 [set alpha 0]
  if alpha > 100 [set alpha 100]
end 

to wiggle ; human procedure
  ifelse superstitious? and danger?
  [face max-one-of cats [distance self]
    rt 180
    rt random 45
    lt random 45
    fd 3]
  [
  rt random 90
  lt random 90
  fd 3]
end 

to look
  if any? neighbors with [pcolor = red] [set red-count red-count + 1]
  if any? neighbors with [any? cats-here] [
    let patches-sighted count neighbors with [pcolor = red and any? cats-here]
    ifelse patches-sighted = 0 and superstitious?
    [ if random 100 > alpha [
      set cat-sighting-memory bl fput count neighbors with [pcolor = red and any? cats-here] cat-sighting-memory
    ]]
    [set cat-sighting-memory bl fput count neighbors with [pcolor = red and any? cats-here] cat-sighting-memory] ;;Remembers the danger of the patch, or 0 if there aren't any red patches under cats
    consider
  ]
end 


;; Calculates the probability of having seen n or more red patches out of memory-length viewings by starting with the probability of 0 or more and removing the probability of 0-(n-1) using a binomial distribution.

to consider ;human procedure
  let p 1.0   ;Represents probability 0 or more
  let n 0
  let danger-impression 0
  let red-probability red-count / (ticks + 3 )
  foreach cat-sighting-memory [   ; Subtracts probability of seeing n patches when memory contains n+1 cases of seeing a patch
    if ( ? >= 1)
    [ set p p - ((item n probability-list) * (1 - red-probability) ^ (memory-length - n) * (red-probability) ^ n )
      set n n + 1
    ]
    set danger-impression danger-impression + ? - 1
  ]

  ifelse p * 100 <= alpha + danger-impression / memory-length
    [
      if not superstitious? [
        set number-of-switches number-of-switches + 1
        set alpha alpha + belief-influence
        set cat-sighting-memory n-values memory-length [1]
        set superstitious? true
        set color orange
        ask humans in-radius human-influence-range [set alpha alpha + other-human-influence]
      ]

    ]
    [
      if superstitious? [
        set number-of-switches number-of-switches + 1
        set superstitious? false
        set color blue
        ask humans in-radius human-influence-range [set alpha alpha - other-human-influence]
        set alpha alpha - belief-influence]
      ]
end 

;; Creates a list where [(item n list) == (memory-length choose n)]
;; seperated to clean up setup code and remove complicated math from it

to setup-consideration-math ;observer procedure
  set probability-list n-values (memory-length + 1) [?]
  let factorial-list (list)
  let factorial 1
  foreach probability-list [
    if ? > 0 [
      set factorial factorial * ?
    ]
    set factorial-list lput factorial factorial-list
  ]
  set probability-list map [(item (memory-length) factorial-list)/((item ? factorial-list) * (item ((memory-length) - ?) factorial-list))] probability-list
end 

There are 5 versions of this model.

Uploaded by When Description Download
Christopher Hartman almost 8 years ago Tiny default value switch Download this version
Christopher Hartman almost 8 years ago Final Model Download this version
Christopher Hartman almost 8 years ago Updated to include memory for humans Download this version
Christopher Hartman almost 8 years ago Added memory to human and danger to patches Download this version
Christopher Hartman almost 8 years ago Initial upload Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.