What a Riot!

What a Riot! preview image

1 collaborator

Default-person David Knoke (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.3.0 • Viewed 7 times • Downloaded 0 times • Run 0 times
Download the 'What a Riot!' 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

;; What A Riot! - NetLogo Code
;; David Knoke, University of Minnesota
;; June 9, 2023
;;
;; Use sliders to set N of agents
breed [bystanders bystander]
breed [instigators instigator]
breed [peacemakers peacemarker]

globals [
  colors   ;; Bystanders = green, Instigators = red, Peacemakers = blue
  initial-green    ;; How many turtles green at start?
  initial-red       ;; How many turtles red at start?
  initial-blue      ;; How many turtles blue at start?
]

turtles-own [
  threshold ; a score to assigned randomly from 1 - K
]

to setup
  clear-all
  ask patches [set pcolor white]    ;; Make all patches white

  create-bystanders N-Bystanders  [  ;; create initial Number of Bystanders
    setxy random-xcor random-ycor
    set color green
    set shape "person"
    set size 2
  ]
  create-instigators N-Instigators  [  ;; create Number of Instigators
    setxy random-xcor random-ycor
    set color red
    set shape "person"
    set size 2
  ]
  create-peacemakers N-Peacemakers  [  ;; create Number of Peacemakers
    setxy random-xcor random-ycor
    set color blue
    set shape "person"
    set size 2
  ]
  ;;  Count how many turtles of each color at start
  set initial-green count turtles with [color = green]
  set initial-red count turtles with [color = red]
  set initial-blue count turtles with [color = blue]
  reset-ticks

  ;; Assign bystander turtles a threshold random number 1 to N-THRESHOLDS
  ask turtles with [color = green] [
   set  threshold 1 + random N-Thresholds ]
end 

to go
  ;; Stop the simulation when Percent-Bystanders = EndSim%
  if (((count turtles with [color = orange]) / initial-green) * 100) >= EndSim%
  [stop]
  ;; Stop if nonterminating run exceeds 50,000 ticks
  if ticks > 50000 [stop]
  move
  recruit
  defect
  tick
end 

to move
  ;; Turtles move one patch in randomly selected 360-degree direction.
  ask turtles [
    right random 360
    forward 1
  ]
end 

to recruit
  ask turtles with [color = green]
    [
      if count turtles in-radius 1 with [color = red] >= threshold
       [set color orange]
  ]
end 

to defect
  ask turtles with [color = orange]
    [
      if count turtles in-radius 1 with [color = blue] >= threshold
       [set color green]
  ]
end 

;; Create plots & monitors in Interface

There is only one version of this model, created 3 days ago by David Knoke.

Attached files

File Type Description Last updated
What a Riot!.png preview Preview for 'What a Riot!' 3 days ago, by David Knoke Download

This model does not have any ancestors.

This model does not have any descendants.