extensions [CF] ;civilian typs breed [civilians civilian] breed [soldiers soldier] breed [enemies enemy] breed [collaborators collaborator] breed [sympathizers sympathizer] breed [refugees refugee] ;civilians killed breed [casualties_by_soldier casualty_by_soldier] breed [casualties_by_enemy casualty_by_enemy] ;enemies killed breed [dead_enemies dead_enemy] ;counters globals [refugees-fled enemies-killed casualties civilians-killed-enemies civilians-killed-soldiers] civilians-own [ ;fear threshold variables fear_affect fear_learning_rate fear_lambda fear_delta fear_extinction_rate fear_threshold fear_event_count fear_disposition fear_probability fear_memory fear_social_weight ;trust threshold variables trust_affect trust_learning_rate trust_lambda trust_delta trust_extinction_rate trust_threshold trust_event_count trust_disposition trust_memory trust_probability trust_social_weight ;designators for movement behavior friend danger residence ] soldiers-own [ target friendly ] enemies-own [invader] collaborators-own [ ;designators for movement behavior foreign_invader defender ;trust threshold variables for enemy collaborators. Initiated with civilian state change c_trust_affect c_trust_learning_rate c_trust_lambda c_trust_delta c_trust_extinction_rate c_trust_threshold c_trust_event_count c_trust_disposition c_trust_memory c_trust_probability c_trust_social_weight ] sympathizers-own [ ;designators for movement bevhavior terrorist liberator ;fear threshold for friendly sympathizers. Initiated with civilian state change s_fear_affect s_fear_learning_rate s_fear_lambda s_fear_delta s_fear_extinction_rate s_fear_threshold s_fear_event_count s_fear_disposition s_fear_probability s_fear_memory s_fear_social_weight ] patches-own [ ;area checks. If true, then the patch will exhibit a color change that will affect the civilians in the vicinity engagement-area? atrocity-area? secure-area? fear-area? dead-body? ] to setup clear-all setup-civilians setup-soldiers setup-enemies reset-ticks end to go ;slider interface determines length of the simulation. Default is 336 hours (2 weeks) if ticks >= hours [stop] ;movement of the dfferent agents move-civilians move-collaborators move-sympathizers move-enemies move-soldiers move-refugees ;stochastic death determination based on Soldier proximity kill-enemies if count enemies = 0 [ stop ] ;stochastic death determination based on enemy proximity kill-soldiers if count soldiers = 0 [ stop ] ;stochastic death determinatino based on enemy or Soldier proximity, checks civilians, collaborators, and sympathizers kill-civilians if count civilians = 0 [ stop ] ;searches the area around the patch to determine whether certain boolean variables are true or false check-patches ;based on the boolean values, changes patch properties change-patches ;checks the area around the civilian and updates the fear and trust variables update-affect ;samples the area around each civilian and determines the probability of fear or trust events occuring update-probability ;uses the affect, probability, and social formula to determine a disposition value update-disposition ;if the disposition value is greater than zero, a stochastic state change determinatino is performed change-states tick end to setup-civilians ;civilians randomly placed on the map. default is 100, but number can be adjusted with a slider create-civilians civilian-number [setxy random-xcor random-ycor] ;civilian initialization. This is for neutral, default civilians. Other types will be initialized following a state change ask civilians [ ;regular civilians are a green person set shape "person" set color green set size 12 ;;setxy of residence of self, the agent will remain in proximity to their residence unless their residence resides in a fear or conflict area in which case they will seek a safer residence (internally displaced) set residence patch-here ;;this stores the location of the agent in residence ;all of the agent_zero vareiables are initialized here set fear_delta 0 set fear_lambda 1 set fear_learning_rate (random 50 + 1) / 100 ;learning rate set to a value between .01 and .5 set fear_extinction_rate extinction_rate set fear_threshold (random 10 + 2) / 10 ;threshold value is between .2 and 1.1 set fear_event_count 0 set fear_disposition 0 set fear_affect 0 set fear_probability 0 set fear_memory [] repeat memory_length [set fear_memory lput random-float 0 fear_memory] set fear_delta 0 set fear_social_weight random (100 + 1) / 1000 ;assigns a social weight to the sum of all other civilians emotional and rational values between .001 and .10 ;;the trust disposition is initialized and calculated independently of the fear disposition. The random variable assignements are assigned the same as the fear set trust_lambda 1 set trust_learning_rate (random 50 + 1) / 100 set trust_extinction_rate extinction_rate set trust_threshold (random 10 + 2) / 10 set trust_event_count 0 set trust_disposition 0 set trust_probability 0 set trust_affect 0 set trust_memory [] repeat memory_length [set trust_memory lput random-float 0 trust_memory] set trust_delta 0 set trust_social_weight random (1000 + 1) / 10000 ] end to setup-soldiers ;soldiers are dark blue and assigned random locations on the map. Number is determined by slider, but the default is 10. create-soldiers soldier-number [setxy random-xcor random-ycor] ask soldiers [ set shape "person" set color blue - 2 set size 12 ] end to setup-enemies ;enemies are dark red and assigned random locations on the map. Number is determined by slider, but the default is 20. create-enemies enemy-number [setxy random-xcor random-ycor] ask enemies [ set shape "person" set color red - 2 set size 12 ] end to move-civilians ask civilians [ set friend one-of soldiers set danger one-of enemies ;;set conditionals: first, check for map edge. if xcor < 1 or xcor > 399 or ycor < 1 or ycor > 399 [ right 180 fd 3 ] ;Second, check for danger. Will attempt to keep a Soldier between themselves and enemy. if pcolor = red or pcolor = orange [ facexy [xcor] of friend + ([xcor] of friend - [xcor] of danger) / 2 [ycor] of friend + ([ycor] of friend - [ycor] of danger) / 2 fd 3 ] ;Third, check for security and make new residence if pcolor = blue [ set residence patch-here ] ;last, check distance from residence and turn around if a threshold is reached ifelse distance residence > 20 [ face residence fd 3 ] ;civilian will move randomly in own neighborhood [right random 360 fd 3 ] ] end to move-collaborators ask collaborators [ set defender one-of enemies set foreign_invader one-of soldiers ;collaborators will attempt to keep themselves in between a Soldier and an Enemy facexy ([xcor] of defender + [xcor] of foreign_invader) / 2 ([ycor] of defender + [ycor] of foreign_invader) / 2 ifelse random 10 > 4 [fd 3][back 1] ] end to move-sympathizers ask sympathizers [ set liberator one-of soldiers set terrorist one-of enemies ;sympathizers will attempt to keep themselves in between a Soldier and an Enemy facexy ([xcor] of liberator + [xcor] of terrorist) / 2 ([ycor] of liberator + [ycor] of terrorist) / 2 ifelse random 10 > 4 [fd 3][back 1] ] end to move-enemies ask enemies [ ; searches in a cone for Soldiers. If it finds one, it will move towards that Soldier until itself or the Soldier are dead ifelse invader = true [face invader right random 90 left random 90 forward 3] [ if xcor < 5 or xcor > 395 or ycor < 5 or ycor > 395 [ right 180] if any? soldiers in-cone 60 100 [ set invader one-of soldiers in-cone 60 100 face invader ifelse random 10 > 3 [right random 90 back 3][right random 45 fd 5]] right random 90 left random 90 fd 4] ] end ;first function is the "seek and destroy" mission for Soldiers ;;to move-soldiers ; ;searches in a cone for enemies. If the Soldier finds one, it will move towards that enemy until itself or the enemy are dead ; ; ask soldiers [ ; ifelse target = true ; [face target ; right random 60 ; left random 60 ; forward 4] ; [ ; if xcor < 5 or xcor > 395 or ycor < 5 or ycor > 395 [ ; right 180] ; if any? enemies in-cone 100 135 [ ; ifelse random 10 < 2 [rt random 360] ; [set target one-of enemies in-cone 100 135 ; face target]] ; right random 75 ; left random 75 ; forward 5] ; ;ifelse random 10 < 2 [rt random 360] ; ;[set target one-of enemies ; ; face target] ; ;forward 5 ; ] ;end ;second function of same name is the broad, global protect and secure civilians mission for Soldiers ;to move-soldiers ; ask soldiers [ ; set target one-of enemies ; set friendly one-of civilians ; ;Soldiers will attempt to keep themselves in between a Civilian and an Enemy ; facexy ([xcor] of target + [xcor] of friendly) / 2 ; ([ycor] of target + [ycor] of friendly) / 2 ; ifelse random 10 > 4 [fd 5][back 1] ; ] ;end ;third function of same name is a local protection tactic to move-soldiers ask soldiers [ set target min-one-of enemies [distance myself] set friendly min-one-of civilians [distance myself] facexy ([xcor] of target + [xcor] of friendly) / 2 ([ycor] of target + [ycor] of friendly) / 2 ifelse random 10 > 4 [fd 5][back 1] ] end to move-refugees ;if the refugee state change occurs, the civilian will move towards the edge of the map and leave the area (will "die" and update a counter) ask refugees [ if xcor < 5 or xcor > 395 or ycor < 5 or ycor > 395 [ set refugees-fled refugees-fled + 1 show refugees-fled die] fd 5 ] end to check-patches ;; patches check for agent types around them and assign a boolean true/false to their boolean variables ask patches [ set engagement-area? ( count soldiers in-radius-nowrap 5 > 0 and count enemies in-radius-nowrap 5 > 0 ) ;set atrocity-area? ( count enemies-on neighbors > 0 and count civilians-on neighbors 3 > 0 ) set secure-area? (count soldiers in-radius-nowrap 3 > 0 and count enemies in-radius-nowrap 3 = 0 ) set fear-area? ( count enemies in-radius-nowrap 3 > 0 and count soldiers in-radius-nowrap 3 = 0 ) ] end to change-patches ;; changes the color of the patches based on their 4 boolean values. The color is used by the civilian agens to change their social factors. ask patches [ if secure-area? [ set pcolor blue ask patches in-radius-nowrap 3 [set pcolor blue] ] if fear-area? [ set pcolor orange ask patches in-radius-nowrap 3 [set pcolor orange] ] ;if atrocity-area? [ ;set pcolor black ;] if engagement-area? [ set pcolor red ask patches in-radius-nowrap 10 [set pcolor red] ] ] end to kill-enemies ;; 5% chance per hour for insurgents in proximity of Soldiers to die, unless sympathizers are present, then 10% chance ask enemies [ ifelse count sympathizers in-radius-nowrap 10 > 0 [ if count soldiers in-radius-nowrap 10 > 0 [ if random 10 < 1 [ set enemies-killed enemies-killed + 1 ;; global variable used to count hatch-dead_enemies 1 [ set shape "x" set color black set size 10] die] ] ] [if count soldiers in-radius-nowrap 10 > 0 [ if random 20 < 1 [ set enemies-killed enemies-killed + 1 ;; global variable used to count hatch-dead_enemies 1 [ set shape "x" set color black set size 10] die] ] ] ] end to kill-soldiers ;; 0.5% chance per hour for soldiers in proximity of insurgents to die, unless collaborators are present, then 1% chance ask soldiers [ ifelse count collaborators in-radius-nowrap 10 > 0 [ if count enemies in-radius-nowrap 10 > 0 [ if random 50 < 1 [ set casualties casualties + 1 ;; global variable used to count die ] ] ] [if count enemies in-radius-nowrap 10 > 0 [ if random 100 < 1 [ set casualties casualties + 1 ;; global variable used to count die ] ] ] ] end to kill-civilians ;civilian death rates are determined by presence of Soldiers and enemies and the Soldier and enemy rules of engagement which are chosen in the user interface from 3 levels. ask civilians [ if count soldiers in-radius-nowrap 10 > 0 [ if rules_of_engagement = "restictive" [ if random 200 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] if rules_of_engagement = "balanced" [ if random 100 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] if rules_of_engagement = "liberal" [ if random 50 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] ] if count enemies in-radius-nowrap 25 > 0 [ if enemy_civilian_disposition = "cautious" [ if random 40 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] if rules_of_engagement = "aggresive" [ if random 20 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] if rules_of_engagement = "ruthless" [ if random 5 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] ] ] ask collaborators [ ;collaborator death rates are higher when Soldiers are in the vicinity than neutral civilians and lower with enemies in the area if count soldiers in-radius-nowrap 10 > 0 [ if rules_of_engagement = "restictive" [ if random 100 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] if rules_of_engagement = "balanced" [ if random 50 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] if rules_of_engagement = "liberal" [ if random 25 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] ] if count enemies in-radius-nowrap 25 > 0 [ if enemy_civilian_disposition = "cautious" [ if random 80 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] if rules_of_engagement = "aggresive" [ if random 40 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] if rules_of_engagement = "ruthless" [ if random 10 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] ] ] ask sympathizers [ ;sympathizer death rates are lower with Soldiers in the vicinity and higher when enemies are in the vicinity if count soldiers in-radius-nowrap 10 > 0 [ if rules_of_engagement = "restictive" [ if random 400 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] if rules_of_engagement = "balanced" [ if random 200 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] if rules_of_engagement = "liberal" [ if random 100 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] ] if count enemies in-radius-nowrap 25 > 0 [ if enemy_civilian_disposition = "cautious" [ if random 20 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] if rules_of_engagement = "aggresive" [ if random 10 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] if rules_of_engagement = "ruthless" [ if random 5 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] ] ] ask refugees [ if count soldiers in-radius-nowrap 10 > 0 [ if rules_of_engagement = "restictive" [ if random 200 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] if rules_of_engagement = "balanced" [ if random 100 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] if rules_of_engagement = "liberal" [ if random 50 < 1 [ set civilians-killed-soldiers civilians-killed-soldiers + 1 hatch-casualties_by_soldier 1 [ set shape "x" set color blue + 3 set size 10] die]] ] if count enemies in-radius-nowrap 25 > 0 [ if enemy_civilian_disposition = "cautious" [ if random 40 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] if rules_of_engagement = "aggresive" [ if random 20 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] if rules_of_engagement = "ruthless" [ if random 5 < 1 [ set civilians-killed-enemies civilians-killed-enemies + 1 hatch-casualties_by_enemy 1 [ set shape "x" set color red + 3 set size 10] die]] ] ] end to update-affect ask civilians [ ;if an orange fear area or a red conflict area or an area where civilians have been killed, the fear affect value is increased if pcolor = orange or pcolor = red or count casualties_by_soldier in-radius-nowrap 3 > 0 or count casualties_by_enemy in-radius-nowrap 5 > 0 [set fear_affect fear_affect + (fear_learning_rate * (fear_affect ^ fear_delta) * (fear_lambda - fear_affect))] ;if a blue secure area or an area where Soldiers have defeated enemy forces, the trust affect value is increased if pcolor = blue or count dead_enemies in-radius-nowrap 3 > 0 [set trust_affect trust_affect + (trust_learning_rate * (trust_affect ^ trust_delta) * (trust_lambda - trust_affect))] ;fear extinction procedure if pcolor != orange and pcolor != red and count casualties_by_soldier in-radius-nowrap 5 = 0 and count casualties_by_enemy in-radius-nowrap 5 = 0 [set fear_affect fear_affect + (fear_learning_rate * (fear_affect ^ fear_delta) * fear_extinction_rate * (0 - fear_affect))] ;trust extinction procedure if pcolor != blue and count dead_enemies in-radius-nowrap 5 = 0 [set trust_affect trust_affect + (trust_learning_rate * (trust_affect ^ trust_delta) * trust_extinction_rate * (0 - trust_affect))] ] ask collaborators [ ;only used trust for enemy collaborators as a means to bring them potentially back to a neutral state if pcolor = blue [ set c_trust_affect c_trust_affect + (c_trust_learning_rate * (c_trust_affect ^ c_trust_delta) * (c_trust_lambda - c_trust_affect))] if pcolor != blue [ set c_trust_affect c_trust_affect + (c_trust_learning_rate * (c_trust_affect ^ c_trust_delta) * c_trust_extinction_rate * (0 - c_trust_affect))] ] ask sympathizers [ ;used fear for friendly sympathizers as a means to potentially bring them back to a neutral state if conditions warrant if pcolor = orange or pcolor = red or count casualties_by_soldier in-radius-nowrap 5 > 0 [ set s_fear_affect s_fear_affect + (s_fear_learning_rate * (s_fear_affect ^ s_fear_delta) * (s_fear_lambda - s_fear_affect))] if pcolor != orange and pcolor != red and count casualties_by_soldier in-radius-nowrap 5 = 0 and count casualties_by_enemy in-radius-nowrap 5 = 0 [set s_fear_affect s_fear_affect + (s_fear_learning_rate * (s_fear_affect ^ s_fear_delta) * s_fear_extinction_rate * (0 - s_fear_affect))] ] end to update-probability ask civilians [ ;samples a local area to determine the probability of a fear inducing condition let fear_current_probability (count patches in-radius-nowrap spatial_sample_radius with [pcolor = orange or pcolor = red or count casualties_by_soldier in-radius-nowrap 3 > 0 or count casualties_by_enemy in-radius-nowrap 5 > 0] / (count patches in-radius-nowrap spatial_sample_radius)) set fear_memory but-first fear_memory set fear_memory lput fear_current_probability fear_memory set fear_probability mean fear_memory ;samples a local area to determine the probability of a fear inducing condition let trust_current_probability (count patches in-radius-nowrap spatial_sample_radius with [pcolor = blue or count dead_enemies in-radius-nowrap 3 > 0] / (count patches in-radius-nowrap spatial_sample_radius)) set trust_memory but-first trust_memory set trust_memory lput trust_current_probability trust_memory set trust_probability mean trust_memory ] ask collaborators [ ;samples local area around collaborators to determine probability of a trust (with relation to friendly Soldiers) raising event let c_trust_current_probability (count patches in-radius-nowrap spatial_sample_radius with [pcolor = blue or count casualties_by_enemy in-radius-nowrap 5 > 0] / (count patches in-radius-nowrap spatial_sample_radius)) set c_trust_memory but-first c_trust_memory set c_trust_memory lput c_trust_current_probability c_trust_memory set c_trust_probability mean c_trust_memory ] ask sympathizers [ ;samples a local area around sympathizers to determine probability of a fear inducing situation let s_fear_current_probability (count patches in-radius-nowrap spatial_sample_radius with [pcolor = orange or pcolor = red or count casualties_by_soldier in-radius-nowrap 3 > 0] / (count patches in-radius-nowrap spatial_sample_radius)) set s_fear_memory but-first s_fear_memory set s_fear_memory lput s_fear_current_probability s_fear_memory set s_fear_probability mean s_fear_memory ] end to update-disposition ask civilians [ ;each civilian adds their fear affect value, their fear probability value, and a randomly weighted sum of all of the other civilians afective and rational values. Once summer, they subtract their random fear threshold to determine their disposition set fear_disposition fear_affect + fear_probability + (fear_social_weight * (( sum [fear_affect] of other civilians) + ( sum [fear_probability] of other civilians))) - fear_threshold ;same process as the fear disposition only with the trust variables set trust_disposition trust_affect + trust_probability + (trust_social_weight * (( sum [trust_affect] of other civilians) + ( sum [trust_probability] of other civilians))) - trust_threshold ] ask collaborators [ ;same process as the neutral civilians with a higher social weight due to the much smaller numbers and likely closer ties set c_trust_disposition c_trust_affect + c_trust_probability + (3 * c_trust_social_weight * (( sum [c_trust_affect] of other collaborators) + ( sum [c_trust_probability] of other collaborators))) - c_trust_threshold ] ask sympathizers [ ;same process as the neutral civilians with a higher social weight set s_fear_disposition s_fear_affect + s_fear_probability + (3 * s_fear_social_weight * (( sum [s_fear_affect] of other sympathizers) + ( sum [s_fear_probability] of other sympathizers))) - s_fear_threshold ] end to change-states ask civilians [ ;first checks if both the fear and trust thresholds have been exceeded in the same time step if fear_disposition > 0 and trust_disposition > 0 [ ;uses the netlogo equivalent of a switch procedure to choose from a list of stochastic choices let x random 20 cf:when cf:case [ x < 7 ] [ ;changes state from neutral to a collaborator, initializing the collaborator. The civilian "dies" and a collaborator is "hatched" hatch-collaborators 1 [ set shape "person" set color red + 2 set size 12 set c_trust_lambda 1 set c_trust_learning_rate (random 50 + 1) / 100 set c_trust_extinction_rate extinction_rate set c_trust_threshold (random 10 + 2) / 10 set c_trust_event_count 0 set c_trust_disposition 0 set c_trust_probability 0 set c_trust_affect 0 set c_trust_memory [] repeat memory_length [set c_trust_memory lput random-float 0 c_trust_memory] ;set c_trust_memory [0 0 0 0 0] set c_trust_delta 0 set c_trust_social_weight random 1000 / 10000 ] die] cf:case [ x < 9 ] [ ;sympathizer state change and variable initialization hatch-sympathizers 1 [ set shape "person" set color blue + 2 set size 12 set s_fear_delta 0 set s_fear_lambda 1 set s_fear_learning_rate (random 50 + 1) / 100 set s_fear_extinction_rate extinction_rate set s_fear_threshold (random 10 + 2) / 10 set s_fear_event_count 0 set s_fear_disposition 0 set s_fear_affect 0 set s_fear_probability 0 set s_fear_memory [] repeat memory_length [set s_fear_memory lput random-float 0 s_fear_memory] ;set s_fear_memory [0 0 0 0 0] set s_fear_delta 0 set s_fear_social_weight random 1000 / 10000 ] die] cf:case [x < 12 ] [ ;regugee change state hatch-refugees 1 [ set shape "person" set color yellow set size 12] die ] cf:else [ ;if the random number does not meet any of the CF (choose from) conditions, then the dispositions are dropped below the threshold and the civilian remains in a neutral state for the time being set fear_disposition fear_disposition - 0.5 set trust_disposition trust_disposition - 0.5 ] ] ;CF (switch) procedure for the fear disposition only exceeding 0 if fear_disposition > 0 and trust_disposition < 0 [ let x random 20 cf:when cf:case [ x < 6 ] [ hatch-refugees 1 [ set shape "person" set color yellow set size 12] die] cf:case [ x < 12 ] [ hatch-collaborators 1 [ set shape "person" set color red + 2 set size 12 set shape "person" set color red + 2 set size 12 set c_trust_lambda 1 set c_trust_learning_rate (random 50 + 1) / 100 set c_trust_extinction_rate extinction_rate set c_trust_threshold (random 10 + 2) / 10 set c_trust_event_count 0 set c_trust_disposition 0 set c_trust_probability 0 set c_trust_affect 0 ;set c_trust_memory [] ;repeat memory_length ;[set c_trust_memory lput random-float 0 c_trust_memory] set c_trust_memory [0 0 0 0 0] set c_trust_delta 0 set c_trust_social_weight random 1000 / 10000 ] die] cf:case [ x < 13 ] [ hatch-sympathizers 1 [ set shape "person" set color blue + 2 set size 12 set s_fear_delta 0 set s_fear_lambda 1 set s_fear_learning_rate (random 50 + 1) / 100 set s_fear_extinction_rate extinction_rate set s_fear_threshold (random 10 + 2) / 10 set s_fear_event_count 0 set s_fear_disposition 0 set s_fear_affect 0 set s_fear_probability 0 ;set s_fear_memory [] ;repeat memory_length ;[set s_fear_memory lput random-float 0 s_fear_memory] set s_fear_memory [0 0 0 0 0] set s_fear_delta 0 set s_fear_social_weight random 1000 / 10000 ] die] cf:case [ x < 14 ] [ hatch-enemies 1 [ set shape "person" set color red set size 12] die] cf:else [ set fear_disposition fear_disposition - 0.5 ] ] ;CF (switch) procedure when only the trust disposition is greated than 0 if fear_disposition < 0 and trust_disposition > 0 [ let x random 20 cf:when cf:case [ x < 6 ] [ hatch-sympathizers 1 [ set shape "person" set color blue + 2 set size 12 set s_fear_delta 0 set s_fear_lambda 1 set s_fear_learning_rate (random 50 + 1) / 100 set s_fear_extinction_rate extinction_rate set s_fear_threshold (random 10 + 2) / 10 set s_fear_event_count 0 set s_fear_disposition 0 set s_fear_affect 0 set s_fear_probability 0 ;set s_fear_memory [] ;repeat memory_length ;[set s_fear_memory lput random-float 0 s_fear_memory] set s_fear_memory [0 0 0 0 0] set s_fear_delta 0 set s_fear_social_weight random 1000 / 10000 ] die] cf:else [ set trust_disposition trust_disposition - 0.5 ] ] ] ;collaborator decisions when threshold trust value is exceeded ask collaborators [ if c_trust_disposition > 0 [ let x random 20 cf:when cf:case [ x < 10 ] [ hatch-civilians 1 [ set shape "person" set color green set size 12 set residence patch-here ;;this stores the location of the agent in residence set fear_delta 0 set fear_lambda 1 set fear_learning_rate (random 50 + 1) / 100 set fear_extinction_rate extinction_rate set fear_threshold (random 10 + 2) / 10 set fear_event_count 0 set fear_disposition 0 set fear_affect 0 set fear_probability 0 set fear_memory [] repeat memory_length [set fear_memory lput random-float 0 fear_memory] set fear_delta 0 set fear_social_weight random 1000 / 10000 set trust_lambda 1 set trust_learning_rate (random 50 + 1) / 100 set trust_extinction_rate extinction_rate set trust_threshold (random 10 + 2) / 10 set trust_event_count 0 set trust_disposition 0 set trust_probability 0 set trust_affect 0 set trust_memory [] repeat memory_length [set trust_memory lput random-float 0 trust_memory] set trust_delta 0 set trust_social_weight random 1000 / 10000] die] cf:case [ x < 11 ] [ hatch-refugees 1 [ set shape "person" set color yellow set size 12] die] cf:else [ set c_trust_disposition c_trust_disposition - 0.5 ] ] ] ;sympathizer decisions when fear threhold is exceeded ask sympathizers [ if s_fear_disposition > 0 [ let x random 20 cf:when cf:case [ x < 10 ] [ hatch-civilians 1 [ set shape "person" set color green set size 12 set residence patch-here ;;this stores the location of the agent in residence set fear_delta 0 set fear_lambda 1 set fear_learning_rate (random 50 + 1) / 100 set fear_extinction_rate extinction_rate set fear_threshold (random 10 + 2) / 10 set fear_event_count 0 set fear_disposition 0 set fear_affect 0 set fear_probability 0 set fear_memory [] repeat memory_length [set fear_memory lput random-float 0 fear_memory] set fear_delta 0 set fear_social_weight random 1000 / 10000 set trust_lambda 1 set trust_learning_rate (random 50 + 1) / 100 set trust_extinction_rate extinction_rate set trust_threshold (random 10 + 2) / 10 set trust_event_count 0 set trust_disposition 0 set trust_probability 0 set trust_affect 0 set trust_memory [] repeat memory_length [set trust_memory lput random-float 0 trust_memory] set trust_delta 0 set trust_social_weight random 1000 / 10000] die] cf:case [ x < 11 ] [ hatch-refugees 1 [ set shape "person" set color yellow set size 12] die] cf:else [ set s_fear_disposition s_fear_disposition - 0.5 ] ] ] end @#$#@#$#@ GRAPHICS-WINDOW 210 10 819 620 -1 -1 1.5 1 10 1 1 1 0 0 0 1 0 400 0 400 1 1 1 ticks 30.0 CHOOSER 34 120 172 165 filename filename "Basrah.jpg" "Tikrit.jpg" "Kirkuk.jpg" "Mosul.jpg" 1 BUTTON 35 165 128 198 import map import-pcolors-rgb filename NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 20 22 84 55 NIL setup NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 88 22 151 55 NIL go T 1 T OBSERVER NIL NIL NIL NIL 0 SLIDER 19 65 191 98 hours hours 24 504 336.0 1 1 hours HORIZONTAL SLIDER 19 212 196 245 civilian-number civilian-number 1 1000 100.0 1 1 civilians HORIZONTAL SLIDER 20 249 198 282 soldier-number soldier-number 1 100 20.0 1 1 Soldiers HORIZONTAL SLIDER 22 289 195 322 enemy-number enemy-number 1 100 20.0 1 1 enemy HORIZONTAL SLIDER 22 354 194 387 memory_length memory_length 1 10 5.0 1 1 NIL HORIZONTAL CHOOSER 13 433 159 478 rules_of_engagement rules_of_engagement "restrictive" "balanced" "liberal" 1 CHOOSER 13 477 182 522 enemy_civilian_disposition enemy_civilian_disposition "cautious" "aggressive" "ruthless" 2 MONITOR 852 167 919 212 NIL casualties 17 1 11 MONITOR 853 213 942 258 NIL enemies-killed 17 1 11 MONITOR 919 169 1051 214 NIL civilians-killed-soldiers 17 1 11 MONITOR 853 257 988 302 NIL civilians-killed-enemies 17 1 11 SLIDER 22 322 194 355 extinction_rate extinction_rate 0.01 1 0.5 0.01 1 NIL HORIZONTAL SLIDER 24 387 196 420 spatial_sample_radius spatial_sample_radius 1 6 6.0 1 1 NIL HORIZONTAL MONITOR 854 302 942 347 NIL refugees-fled 17 1 11 MONITOR 853 32 972 77 collaborators count collaborators 17 1 11 MONITOR 854 77 974 122 sympathizers count sympathizers 17 1 11 MONITOR 853 123 911 168 enemies count enemies 17 1 11 BUTTON 40 552 103 585 NIL go NIL 1 T OBSERVER NIL NIL NIL NIL 1 MONITOR 856 383 945 428 NIL count civilians 17 1 11 @#$#@#$#@ ## WHAT IS IT? (a general understanding of what the model is trying to show or explain) ## HOW IT WORKS (what rules the agents use to create the overall behavior of the model) ## HOW TO USE IT (how to use the model, including a description of each of the items in the Interface tab) ## THINGS TO NOTICE (suggested things for the user to notice while running the model) ## THINGS TO TRY (suggested things for the user to try to do (move sliders, switches, etc.) with the model) ## EXTENDING THE MODEL (suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.) ## NETLOGO FEATURES (interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features) ## RELATED MODELS (models in the NetLogo Models Library and elsewhere which are of related interest) ## CREDITS AND REFERENCES (a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links) @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 airplane true 0 Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 arrow true 0 Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box false 0 Polygon -7500403 true true 150 285 285 225 285 75 150 135 Polygon -7500403 true true 150 135 15 75 150 15 285 75 Polygon -7500403 true true 15 75 15 225 150 285 150 135 Line -16777216 false 150 285 150 135 Line -16777216 false 150 135 15 75 Line -16777216 false 150 135 285 75 bug true 0 Circle -7500403 true true 96 182 108 Circle -7500403 true true 110 127 80 Circle -7500403 true true 110 75 80 Line -7500403 true 150 100 80 30 Line -7500403 true 150 100 220 30 butterfly true 0 Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 Circle -16777216 true false 135 90 30 Line -16777216 false 150 105 195 60 Line -16777216 false 150 105 105 60 car false 0 Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 Circle -16777216 true false 180 180 90 Circle -16777216 true false 30 180 90 Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 Circle -7500403 true true 47 195 58 Circle -7500403 true true 195 195 58 circle false 0 Circle -7500403 true true 0 0 300 circle 2 false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 cow false 0 Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 Polygon -7500403 true true 73 210 86 251 62 249 48 208 Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 cylinder false 0 Circle -7500403 true true 0 0 300 dot false 0 Circle -7500403 true true 90 90 120 face happy false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 face neutral false 0 Circle -7500403 true true 8 7 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Rectangle -16777216 true false 60 195 240 225 face sad false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 fish false 0 Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 Circle -16777216 true false 215 106 30 flag false 0 Rectangle -7500403 true true 60 15 75 300 Polygon -7500403 true true 90 150 270 90 90 30 Line -7500403 true 75 135 90 135 Line -7500403 true 75 45 90 45 flower false 0 Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 Circle -7500403 true true 85 132 38 Circle -7500403 true true 130 147 38 Circle -7500403 true true 192 85 38 Circle -7500403 true true 85 40 38 Circle -7500403 true true 177 40 38 Circle -7500403 true true 177 132 38 Circle -7500403 true true 70 85 38 Circle -7500403 true true 130 25 38 Circle -7500403 true true 96 51 108 Circle -16777216 true false 113 68 74 Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 house false 0 Rectangle -7500403 true true 45 120 255 285 Rectangle -16777216 true false 120 210 180 285 Polygon -7500403 true true 15 120 150 15 285 120 Line -16777216 false 30 120 270 120 leaf false 0 Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 line true 0 Line -7500403 true 150 0 150 300 line half true 0 Line -7500403 true 150 0 150 150 pentagon false 0 Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 person false 0 Circle -7500403 true true 110 5 80 Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 Rectangle -7500403 true true 127 79 172 94 Polygon -7500403 true true 195 90 240 150 225 180 165 105 Polygon -7500403 true true 105 90 60 150 75 180 135 105 plant false 0 Rectangle -7500403 true true 135 90 165 300 Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 sheep false 15 Circle -1 true true 203 65 88 Circle -1 true true 70 65 162 Circle -1 true true 150 105 120 Polygon -7500403 true false 218 120 240 165 255 165 278 120 Circle -7500403 true false 214 72 67 Rectangle -1 true true 164 223 179 298 Polygon -1 true true 45 285 30 285 30 240 15 195 45 210 Circle -1 true true 3 83 150 Rectangle -1 true true 65 221 80 296 Polygon -1 true true 195 285 210 285 210 240 240 210 195 210 Polygon -7500403 true false 276 85 285 105 302 99 294 83 Polygon -7500403 true false 219 85 210 105 193 99 201 83 square false 0 Rectangle -7500403 true true 30 30 270 270 square 2 false 0 Rectangle -7500403 true true 30 30 270 270 Rectangle -16777216 true false 60 60 240 240 star false 0 Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 target false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 Circle -7500403 true true 60 60 180 Circle -16777216 true false 90 90 120 Circle -7500403 true true 120 120 60 tree false 0 Circle -7500403 true true 118 3 94 Rectangle -6459832 true false 120 195 180 300 Circle -7500403 true true 65 21 108 Circle -7500403 true true 116 41 127 Circle -7500403 true true 45 90 120 Circle -7500403 true true 104 74 152 triangle false 0 Polygon -7500403 true true 150 30 15 255 285 255 triangle 2 false 0 Polygon -7500403 true true 150 30 15 255 285 255 Polygon -16777216 true false 151 99 225 223 75 224 truck false 0 Rectangle -7500403 true true 4 45 195 187 Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 Rectangle -1 true false 195 60 195 105 Polygon -16777216 true false 238 112 252 141 219 141 218 112 Circle -16777216 true false 234 174 42 Rectangle -7500403 true true 181 185 214 194 Circle -16777216 true false 144 174 42 Circle -16777216 true false 24 174 42 Circle -7500403 false true 24 174 42 Circle -7500403 false true 144 174 42 Circle -7500403 false true 234 174 42 turtle true 0 Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 wheel false 0 Circle -7500403 true true 3 3 294 Circle -16777216 true false 30 30 240 Line -7500403 true 150 285 150 15 Line -7500403 true 15 150 285 150 Circle -7500403 true true 120 120 60 Line -7500403 true 216 40 79 269 Line -7500403 true 40 84 269 221 Line -7500403 true 40 216 269 79 Line -7500403 true 84 40 221 269 wolf false 0 Polygon -16777216 true false 253 133 245 131 245 133 Polygon -7500403 true true 2 194 13 197 30 191 38 193 38 205 20 226 20 257 27 265 38 266 40 260 31 253 31 230 60 206 68 198 75 209 66 228 65 243 82 261 84 268 100 267 103 261 77 239 79 231 100 207 98 196 119 201 143 202 160 195 166 210 172 213 173 238 167 251 160 248 154 265 169 264 178 247 186 240 198 260 200 271 217 271 219 262 207 258 195 230 192 198 210 184 227 164 242 144 259 145 284 151 277 141 293 140 299 134 297 127 273 119 270 105 Polygon -7500403 true true -1 195 14 180 36 166 40 153 53 140 82 131 134 133 159 126 188 115 227 108 236 102 238 98 268 86 269 92 281 87 269 103 269 113 x false 0 Polygon -7500403 true true 270 75 225 30 30 225 75 270 Polygon -7500403 true true 30 75 75 30 270 225 225 270 @#$#@#$#@ NetLogo 6.0.2 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 0.0 1.0 0.0 1 1.0 0.0 0.2 0 0.0 1.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ 0 @#$#@#$#@