mass attack scenario
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This model simulates a mass attack scenario in a campus-like environment. It compares outcomes of knife attacks vs. gun attacks, inspired by Xi & Chan (2019). The goal is to understand how weapon type, student responses (fight/flee), and law enforcement delays influence the number of casualties.
HOW IT WORKS
The attacker moves first each tick and strikes students within weapon range with a weapon-specific accuracy.
Students nearby choose either to fight (with small probability) or flee (step away from the attacker). Fighters may collectively overpower the attacker, while fleers are safer against knives but risk collateral damage against guns.
Law enforcement (security for knife, police for both weapons) deploy after the first casualty with a fixed delay and pursue the attacker until they subdue them.
The simulation ends when the attacker is stopped (either by students or law enforcement).
HOW TO USE IT
initial-students (slider): Sets the number of students in the environment.
weapon-choice (chooser): Select either “knife” or “gun.”
setup (button): Creates the network grid, students, and attacker(s).
go (button): Runs the model continuously until the attacker is stopped.
go once (button): Advances the simulation by one tick.
casualties (monitor): Shows total student deaths.
first-casualty-tick (monitor): Shows when the first death occurred.
stopped-by (monitor): Shows who subdued the attacker (students or law).
Alive Students (monitor): Shows how many students survived.
Casualties vs Ticks (plot): Displays casualties over time.
CREDITS AND REFERENCES
Xi, C. & Chan, C. (2019). Comparative risk of mass knife vs. gun attacks: An agent-based modeling study.
Implemented in NetLogo 6.4.0 by M Ali Raza
Comments and Questions
; breeds breed [students student] breed [attackers attacker] breed [securities security] breed [police-officers police-officer] breed [nodes node] undirected-link-breed [roads road] ; agent variables students-own [ mode my-node ] ; mode: "idle" "flee" "fight" attackers-own [ my-node ] securities-own [ my-node deploy-at ] police-officers-own[ my-node deploy-at ] ; globals globals [ casualties first-casualty-tick stopped-by weapon-range p-student-fight p-student-flee p-defeat-attacker-base p-student-flee-die p-accuracy security-delay police-delay grid-n ] ; SETUP to setup clear-all set casualties 0 set stopped-by "" set first-casualty-tick -1 if not is-number? grid-n [ set grid-n 20 ] setup-synthetic-network if count nodes = 0 [ user-message "⚠ No nodes created – check grid-n" stop ] set-params-by-weapon ; students create-students initial-students [ set shape "person" set color blue set size 0.7 set mode "idle" set my-node one-of nodes if my-node != nobody [ move-to my-node ] ] ; attacker create-attackers 1 [ set shape "person" set color red set size 1.1 set my-node one-of nodes if my-node != nobody [ move-to my-node ] ] ; security (knife only) if weapon-choice = "knife" [ create-securities 1 [ set shape "person" set color gray set size 1.0 set my-node one-of nodes if my-node != nobody [ move-to my-node ] set deploy-at -1 ] ] ; police (always) create-police-officers 1 [ set shape "person" set color black set size 1.0 set my-node one-of nodes if my-node != nobody [ move-to my-node ] set deploy-at -1 ] reset-ticks end ; GRID NETWORK to setup-synthetic-network ; default grid size if not provided if grid-n < 2 [ set grid-n 20 ] let spacing (max-pxcor - min-pxcor) / (grid-n - 1) ; create grid-n × grid-n nodes foreach (n-values grid-n [ i -> i ]) [ i -> foreach (n-values grid-n [ j -> j ]) [ j -> create-nodes 1 [ setxy (min-pxcor + i * spacing) (min-pxcor + j * spacing) set color gray set size 0.2 ] ] ] ; sanity check if count nodes = 0 [ user-message (word "⚠ grid-n=" grid-n " produced no nodes") stop ] ; connect right and up neighbors ask nodes [ let right-node one-of nodes with [ ycor = [ycor] of myself and abs(xcor - [xcor] of myself) = spacing ] if right-node != nobody [ create-roads-with (turtle-set right-node) ] let up-node one-of nodes with [ xcor = [xcor] of myself and abs(ycor - [ycor] of myself) = spacing ] if up-node != nobody [ create-roads-with (turtle-set up-node) ] ] end ; PARAMETERS to set-params-by-weapon if weapon-choice = "gun" [ set weapon-range 1 set p-student-fight 0.025 set p-student-flee 0.975 set p-defeat-attacker-base 0.131 set p-student-flee-die 0.20 set p-accuracy 0.48 set security-delay -1 set police-delay 3 ] if weapon-choice = "knife" [ set weapon-range 0.2 set p-student-fight 0.05 set p-student-flee 0.95 set p-defeat-attacker-base 0.1965 set p-student-flee-die 0 set p-accuracy 0.72 set security-delay 2 set police-delay 2 ] end ; MAIN LOOP to go if not any? attackers [ stop ] attacker-act students-react law-enforcement-act if stopped-by != "" [ stop ] tick end ; ATTACKER to attacker-act ask attackers [ let inrange students with [ distance myself <= weapon-range ] ifelse any? inrange [ let fighters inrange with [ mode = "fight" ] ifelse any? fighters [ ask fighters [ if random-float 1 < p-accuracy [ inc-casualty self ] ] if weapon-choice = "gun" [ ask inrange with [ mode = "flee" ] [ if random-float 1 < p-student-flee-die [ inc-casualty self ] ] ] ] [ ask inrange [ if random-float 1 < p-accuracy [ inc-casualty self ] ] ] ] [ let nbrs [link-neighbors] of my-node if any? nbrs [ set my-node one-of nbrs move-to my-node ] ] ] end to inc-casualty [ victim ] set casualties casualties + 1 if first-casualty-tick < 0 [ set first-casualty-tick ticks ] ask victim [ die ] end ; STUDENTS to students-react let atk one-of attackers if atk = nobody [ stop ] ask students [ set mode "idle" ] let nearby students with [ distance atk <= weapon-range ] ask nearby [ ifelse (random-float 1 < p-student-fight) [ set mode "fight" ] [ set mode "flee" ] ] let fighters students with [ mode = "fight" and distance atk <= weapon-range ] let n count fighters if n > 0 [ let per-fighter-prob p-defeat-attacker-base * n if per-fighter-prob > 1 [ set per-fighter-prob 1 ] if any? fighters with [ random-float 1 < per-fighter-prob ] [ ask attackers [ die ] set stopped-by "students" stop ] ] ask students with [ mode = "flee" ] [ flee-one-step-away-from atk ] end to flee-one-step-away-from [ target ] if my-node != nobody [ let nbrs [link-neighbors] of my-node if any? nbrs [ let next max-one-of nbrs [ distance target ] set my-node next move-to my-node ] ] end ; LAW ENFORCEMENT to law-enforcement-act if first-casualty-tick >= 0 [ if weapon-choice = "knife" [ ask securities [ if deploy-at < 0 [ set deploy-at first-casualty-tick + security-delay ] ] ] ask police-officers [ if deploy-at < 0 [ set deploy-at first-casualty-tick + police-delay ] ] ] let atk one-of attackers if atk != nobody [ if weapon-choice = "knife" [ ask securities with [ deploy-at >= 0 and ticks >= deploy-at ] [ move-one-step-towards [my-node] of atk if my-node = [my-node] of atk [ ask attackers [ die ] set stopped-by "law" ] ] ] ask police-officers with [ deploy-at >= 0 and ticks >= deploy-at ] [ move-one-step-towards [my-node] of atk if my-node = [my-node] of atk [ ask attackers [ die ] set stopped-by "law" ] ] ] end to move-one-step-towards [ target-node ] let nbrs [link-neighbors] of my-node if any? nbrs [ let next min-one-of nbrs [ distance target-node ] set my-node next move-to my-node ] end
There is only one version of this model, created 2 days ago by Muhammad Ali Raza.
Attached files
| File | Type | Description | Last updated | |
|---|---|---|---|---|
| mass attack scenario.png | preview | Preview for 'mass attack scenario' | 2 days ago, by Muhammad Ali Raza | Download |
This model does not have any ancestors.
This model does not have any descendants.
Download this model