Insurgents & Soldiers Fighting

Insurgents & Soldiers Fighting 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 163 times • Downloaded 19 times • Run 0 times
Download the 'Insurgents & Soldiers Fighting' 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?

ABM of insurgents and soldiers fighting to eliminate one another in jungle terrain. Source: Chapter 8 Insurging in David Knoke. 2025. Network Collective Action: Agent-Based Models of Pandemics, Riots, Social Movements, Insurrections and Insurgencies. Cham, Switzerland: Springer Nature. Yicheng Shen is coauthor of this chapter.

HOW IT WORKS

Insurgents conceal themselves in high-density vegetation. If detected by patrolling soldiers, they flee toward nearby high-density patches. Insurgents do not attack alerted soldiers, who move toward a threat and try to kill insurgents. Insurgents attack only unalerted soldiers. Every attack by either side always results in killings. The simulation ends when one side entirely eliminates its enemies.

HOW TO USE IT

Use sliders to set the numbers of insurgents and soldiers and their respective kill rates.

THINGS TO NOTICE

When are the numbers of combatants or the lethality of their weapons a more decisive factor in the outcome?

THINGS TO TRY

Raise or lower the two kill rates to simulate differences in effective weapons technology available to each side.

EXTENDING THE MODEL

Add soldier reinforcements and civilian agents who support soldiers or insurgents, as in Scott Wheeler's (2005a, 2005b) guerilla warfare model, modified by Yicheng Shen (29022a, 2022b).

NETLOGO FEATURES

The ABM incorporates Uri Wilensky's (1998) Netlogo Flocking Model to animate small groups of soldiers on patrol searching for insurgents.

RELATED MODELS

Doran, Jim. 2005. “Iruba: An Agent-Based Model of the Guerrilla War Process.” Pp. 198-205 in Representing Social Reality, Pre-Proceedings of the Third Conference of the European Social Simulation Association.

Epstein, Joshua M. 2002. “Modeling Civil Violence: An Agent-Based Computational Approach.” Proceedings of the National Academy of Sciences 99(suppl. 3):7243-7250.

Sink, Jerry Taylor. 2020. “Mao with Smart Phones and Internet? A Comparison of Classic Guerrilla Warfare with Fourth and Fifth Generation Warfare Using an Agent-Based Model for Simulation.” Department of Politics and Policy doctoral dissertation. Claremont, CA: Claremont Graduate University.

CREDITS AND REFERENCES

Shen, Yicheng. 2022a. “Model of Wheeler.” NetLogo Modeling Commons. Evanston, IL: Northwestern University Center for Connected Learning and Computer-Based Modeling. https://modelingcommons.org/account/models/5618

Shen, Yicheng. 2022b. “Be Steady and Popular: A Modern Counter-Insurgency ABM.” NetLogo Modeling Commons. https://modelingcommons.org/account/models/5618

Wheeler, Scott. 2005a. “It Pays to Be Popular: A Study of Civilian Assistance and Guerilla Warfare." Journal of Artificial Societies and Social Simulation 8(4). (Accessed July 3, 2024).

Wheeler, Scott. 2005b. “On the Suitability of NetLogo for the Modelling of Civilian Assistance and Guerrilla Warfare.” DSTO-TN-0623. Edinburgh, South Australia: Australian Defence Science and Technology Organization, Systems Sciences Laboratory.

Wilensky, Uri. 1998. “NetLogo Flocking Model.” Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. http://ccl.northwestern.edu/netlogo/models/Flocking

Comments and Questions

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

Click to Run Model

;;Insurgents & Soldiers Fighting
;; David Knoke, University of Minnesota & Yicheng Shen, Johns Hopkins University
;; August 9, 2024

globals[
     jungle
     Ninsurgentsalive    ;; number of insurgents alive
     Ninsurgentsdead     ;; number of insurgents dead
     Pinsurgentsalive    ;; percentage of insurgents alive
     Pinsurgentsdead     ;; percentage of insurgents dead
     Nsoldiersalive      ;; number of soldiers alive
     Nsoldiersdead       ;; number of soldiers dead
     Psoldiersalive      ;; percentage of soldiers alive
     Psoldiersdead       ;; percentage of soldiers dead
     InsurgentsWin       ;; Insurgents eliminated all soldiers
     SoldiersWin         ;; Soldiers eliminated all insurgents
]

breed [ insurgents insurgent ]
breed [ soldiers soldier ]

insurgents-own [ detect detect_time ]
soldiers-own [ flockmates alert ]
patches-own [ density ]

to setup
  clear-all
  setup_patches
  setup_agents
  reset-ticks
end 

to setup_patches
   ask patches
  [ set density (random 10000) ]
  repeat 2 [  diffuse density 1 ]
  ask patches
  [ set pcolor scale-color green density 9000 1000 ]
  set jungle max-n-of 20 patches [ density ]     ;; Create some high-density jungle patches
end 

to setup_agents
   create-insurgents N-Insurgents
  [ set size 4
    setxy random-xcor random-ycor
    set color red
    set shape "person"
    set detect False
    set detect_time 0
    set InsurgentsWin 0
  ]

  create-soldiers N-Soldiers
  [ set size 4
    set xcor random-normal 0 1
    set ycor random-normal 0 1
    set color blue
    set shape "person"
    set flockmates no-turtles
    set alert False
    set SoldiersWin 0
  ]
end 

to go
  if not any? insurgents [ stop ]
  if not any? soldiers [ stop ]
  ask insurgents [ insurgents_movement ]
  ask soldiers [ soldiers_movement ]
  tally
  tick
end 

to insurgents_movement
  let p max-one-of patches in-radius 20 [ density ]
  if [ density ] of p > density [           ;;  Go to nearest high-density jungle patches to hide from soldiers
    face p
    forward  1 ]
  if any? soldiers in-radius 3              ;; If seen by soliders, stay detected for 20 ticks
  [ set detect_time 20 ]
  ifelse detect_time > 0
  [ set detect True
    face min-one-of turtles with [ color != red ] [ distance myself ]
    set heading heading + 180 + random-normal 0 30
    forward 1
  set detect_time detect_time - 1 ]
  [ set detect False ]
  if any? soldiers with [ alert = False ] in-radius 8   ;; Insurgents  attack nonalert soliders
  [
   insurgents-attack-soldiers
  ]
end 

to soldiers_movement
  if any? insurgents in-radius 3
  or any? soldiers with [ alert = True ] in-radius 1
  [ set alert True ]
  ifelse any? insurgents with [ detect = True ]  in-radius 15
  [
   ifelse alert = True
  [ face min-one-of insurgents with [ detect = True ] [ distance myself ]
    set heading heading
    forward 1 ]
  [ flock
    forward 1 ]
  if any? insurgents-here
  [ soldiers-attack-insurgents ]
  ]
   [ set alert False
    flock
    forward 1 ]
end 

to soldiers-attack-insurgents
  let x random 100
  ifelse x > Soldier_kill_rate           ;; Default kill rate is 50% of insurgents, 50% of soldiers
  [
  ask min-one-of insurgents with [ detect = True ] [ distance myself ] [ die ]
  ]
  [ die ]
end 

to insurgents-attack-soldiers
  set detect True
  let x random 100
  ifelse x > Insurgent_kill_rate                          ; 70% kill soldier and 30% insurgent dies
  [ die ]
  [ let insurgent-target one-of soldiers with [ alert = False ] in-radius 8
    ask insurgent-target [ die ]
  ask soldiers in-radius 8 [ set alert True ]]
end 


;;  Count the numbers and percentages of alive and dead insurgents and soldiers

to tally
  set Ninsurgentsalive count turtles  with [ color = red ]
  set Ninsurgentsdead (N-Insurgents - Ninsurgentsalive)
  set Nsoldiersalive count turtles  with [ color = blue ]
  set Nsoldiersdead (N-Soldiers - Nsoldiersalive)
  set Psoldiersalive (Nsoldiersalive / N-Soldiers) * 100
  set Psoldiersdead (Nsoldiersdead / N-Soldiers) * 100
  set Pinsurgentsalive (Ninsurgentsalive / N-Insurgents) * 100
  set Pinsurgentsdead (Ninsurgentsdead / N-Insurgents) * 100
;; Change one of two monitors to indicate which side eliminated the other
  if not any? turtles with [ color = red ] [ set SoldiersWin 1 ]
  if not any? turtles with [ color = blue ] [ set InsurgentsWin 1 ]
end 




;; flocking code

to flock
  find-flockmates
  let nearest-neighbor min-one-of flockmates [distance myself]
  if any? flockmates
    [
      ifelse distance nearest-neighbor < 1
        [ separate ]
        [ align
          cohere ] ]
end 

to find-flockmates
  set flockmates other soldiers in-radius 8
end 

to find-nearest-neighbor
  let nearest-neighbor min-one-of flockmates [distance myself]
end 

;;; SEPARATE

to separate
  let nearest-neighbor min-one-of flockmates [distance myself]
  turn-away ([heading] of nearest-neighbor) 1.5
end 

;;; ALIGN

to align  ;; turtle procedure
  turn-towards average-flockmate-heading 5
end 

to-report average-flockmate-heading
  let x-component sum [dx] of flockmates
  let y-component sum [dy] of flockmates
  ifelse x-component = 0 and y-component = 0
    [ report heading ]
    [ report atan x-component y-component ]
end 

to cohere
  turn-towards average-heading-towards-flockmates 3
end 

to-report average-heading-towards-flockmates
  let x-component mean [sin (towards myself + 180)] of flockmates
  let y-component mean [cos (towards myself + 180)] of flockmates
  ifelse x-component = 0 and y-component = 0
    [ report heading ]
    [ report atan x-component y-component ]
end 

to turn-towards [new-heading max-turn]
  turn-at-most (subtract-headings new-heading heading) max-turn
end 

to turn-away [new-heading max-turn]
  turn-at-most (subtract-headings heading new-heading) max-turn
end 

to turn-at-most [turn max-turn]
  ifelse abs turn > max-turn
    [ ifelse turn > 0
        [ rt max-turn ]
        [ lt max-turn ] ]
    [ rt turn ]
end 

There are 2 versions of this model.

Uploaded by When Description Download
David Knoke 3 months ago added coauthor Download this version
David Knoke 3 months ago Initial upload Download this version

Attached files

File Type Description Last updated
Insurgents & Soldiers Fighting.png preview Preview for 'Insurgents & Soldiers Fighting' 3 months ago, by David Knoke Download

This model does not have any ancestors.

This model does not have any descendants.