indiscriminate violence| suppressive model

indiscriminate violence| suppressive model preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.1 • Viewed 82 times • Downloaded 1 time • Run 0 times
Download the 'indiscriminate violence| suppressive model' 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 [villagers villager]
breed [soldiers soldier]
breed [rebels rebel]
breed [unfits unfit]
breed [deads dead]




globals [ ;; Global variables.
  total-villager
  total-soldier
  total-rebel
  total-dead
  total-unfit
]



turtles-own[  ;; Turtle variables.
  turn-check
  wall-turn-check
  age
]

to setup

  set-default-shape villagers "person business"
  set-default-shape soldiers "person police"
  set-default-shape rebels "person soldier"
  set-default-shape unfits "person student"
  set-default-shape deads "person"
  clear-all
  reset-ticks
  ask patches [set pcolor grey - 3]

  create-villagers CIV [
    set color grey
    setxy random-xcor random-ycor
    set age (random 100) / UNF
    if age < 1 [set breed unfits set color pink - 1]
  ]


  create-soldiers COIN [
    set color brown + 3
    setxy random-xcor random-ycor
    set age -2
  ]


  create-rebels INS [
    set color brown + 2
  setxy random-xcor random-ycor
    set age (random 100)
  ]

  ask turtles [set size 0.5]
end 

to go              ;; the fun beginns

  tick
  update-globals
  do-plots
  set-default-shape villagers "person business"
  set-default-shape soldiers "person police"
  set-default-shape rebels "person soldier"
  set-default-shape unfits "person student"
  set-default-shape deads "person"

  ask villagers [
  forward 0.2
    wander
    let current-villager self
   let persuade  random count villagers + random 1000
    if persuade <  random count deads [ask rebels with [distance current-villager < 1] [soothe]]
  ]

  ask soldiers [
    ;;let closest-home min-one-of patches with [pcolor = green] [distance myself]
    ;;face  closest-home
    wander
    forward 0.1
    let current-soldier self
    let attack random 100
    if attack < 80 [ask rebels with [distance current-soldier < 1] [kill]]
  ]


  ask rebels [
    ;;let dice random 3
    ;;let change (dice - 1)
    ;;set heading (heading + change)
    ;;let closest-rebel min-one-of (other rebels) [distance myself]
    forward 0.2
    wander
    let current-rebel self
    let persuade random count rebels + random 1000
    if persuade < random count villagers [ask villagers with [distance current-rebel < 1] [radicalize]]
    let attack random 100
    if attack < 5 [ask soldiers with [distance current-rebel < 1] [kill]]
  ]

  ask unfits [
    wander
    ;;let closest-home min-one-of patches with [pcolor = grey] [distance myself]
    ;;face  closest-home
    fd 0.2
]




  if IV? [
    carefully [ask  up-to-n-of random 8 turtles with  [age > -1]  [kill]] [print error-message]
  carefully [ask  up-to-n-of random 2 rebels [soothe]] [print error-message]
  ]
end 
;; one-of patches with [pcolor = grey]
;; while patch witch pcolor grey - 3 (other patches)



;; definitions

to reinforce
  create-soldiers COIN [
    set color brown + 2
    setxy random-xcor random-ycor
  ]
end 

to soothe
  set breed villagers
  set color grey
end 

to radicalize
  set breed rebels
  set color brown + 1
end 

to kill
  set breed deads
  set color black
  set age -2
end 

to wander                 ;; Random movement for agents.
  set turn-check random 20
  if turn-check > 15
  [right-turn]
  if turn-check < 5
  [left-turn]
  if [pcolor] of patch-ahead 1 = green
  [wall]
end 

to wall ;;  Turn agent away from wall
    set wall-turn-check random 10
    if wall-turn-check >= 6
    [wall-right-turn]
    if wall-turn-check <= 5
    [wall-left-turn]
end 

to wall-right-turn ;;Generate a random degree of turn for the wall sub-routine.
  rt 170
end 

to wall-left-turn ;;Generate a random degree of turn for the wall sub-routine.
  lt 170
end 

to right-turn ;;Generate a random degree of turn for the wander sub-routine.
  rt random-float 10
end 

to left-turn   ;;Generate a random degree of turn for the wander sub-routine.
  lt random-float 10
end 
;;to right-turn
  ;;rt random-float 10
;;end

;;to left-turn
  ;;lt random 10
;;end

;; reporters

to update-globals ;;Set globals to current values for reporters.
  set total-rebel (count rebels)
  set total-soldier (count soldiers)
  set total-villager (count villagers)
  set total-dead (count deads)
  set total-unfit (count unfits)
end 

to do-plots                ;; Update monitors
  set-current-plot "Population Totals"
  set-current-plot-pen "insurgents" plot total-rebel
  set-current-plot-pen "COIN" plot total-soldier
  set-current-plot-pen "Civilains" plot total-villager
  set-current-plot-pen "Dead" plot total-dead
  set-current-plot-pen "Unfit for battle" plot total-unfit
end 

There are 6 versions of this model.

Uploaded by When Description Download
Stefan Baumgartner 25 days ago increased possible insurgents Download this version
Stefan Baumgartner 26 days ago implementing more bugs to fix later Download this version
Stefan Baumgartner 26 days ago fixa da bug Download this version
Stefan Baumgartner 26 days ago something Download this version
Stefan Baumgartner 26 days ago increased CIV amount, lowered turtle size Download this version
Stefan Baumgartner 3 months ago Initial upload Download this version

Attached files

File Type Description Last updated
indiscriminate violence| suppressive model.png preview Preview for 'indiscriminate violence| suppressive model' 3 months ago, by Stefan Baumgartner Download

This model does not have any ancestors.

This model does not have any descendants.