Agent-based modeling of mass shooting case with the counterforce of policemen

Mass shooting cases have caused large casualties worldwide. The counterforce, such as the policemen, is of great significance to reducing casualties, which is the core issue of social safety governance. Therefore, we model both the killing force and counterforce, to explore the crowd dynamics under the shooting. Taking the “Borderline” shooting in 2018 as the target case, the agent-based modeling is applied to back-calculate this dynamic process and explore key behavior rules of individuals. The real death tolls of three classes of agents (civilians, policemen, & killers) are as the real function, based on which we calculate the gaps between real target case and simulations. Eventually, we obtain three optimal solutions, which achieve the least gap or highest matching degree. Besides, we make counterfactual inferences under the optimal solutions, to explore the strategic interactions between policemen and killers. For strategies of killers, we explore different sizes, positions, and moving patterns of the killers. The optimal size of policemen is four to five, for each one killer. For strategies of policemen, we explore the size, locations, and the response time. It indicates that optimal response time of policemen is thirty to forty shots of the killer, and the death of civilians and policemen can be minimized, and the death probability of the killer can be maximized. These findings help to improve public safety governance for our cities. To effectively deal with sudden shooting terrorist cases, patrol routes, reasonable settings, and swift dispatches of the police (stations) should be considered.


Introduction
The shooting violence has posed great threats to domestic and global public safety.Especially in United States, the death rate caused by gun violence is extremely high, and this trend remains stable over decades [1].For each year, this gunfire violence also brings a huge and expensive cost to public health budget.According to statistics reports, we have 313,045 civilians (people) died in gunfire-related violence in America, during 2003 and 2012 [2].The total (direct & indirect) social cost, caused by them, had reached 174.1 billion dollars in 2010 [3].Such tragedies (cases) of large-scale shooting, which take places worldwide every year, have produced huge and negative impacts on the society, in terms of many aspects, such as the death & injury of civilians (victims), damages of infrastructure (public facility), and social disturbances and social instability.Besides, mental damages of civilians are also critical, which is potential and may be often ignored.For some victims, they are not only dead or physical injured unfortunately, but also suffering from mental illness, because of experiencing or witnessing the mass shooting case at site [4].On the other hand, the mass shooting cases to the public, may bring a steep rise in gun sales, because of the demands of self-defense or self-protection for individuals [5], which further leads to social instability and difficulties for gun control.Gun violence has become one of the main causes of death in the group of teenagers and young people [6].To reduce or limit negative impacts of this public safety issues, effective policies should be immediately implemented to prevent gunfire violence, such as stricter gun control, age limitation for carrying guns [6], and it is also necessary to raise public awareness to find appropriate and legal 123 ways of gun storage [7].In the shooting incident, the behavior and interaction between the shooter (the attacker) and the civilian (being attacked) will affect the outcomes of this incident.At the same time, as an important role of anti-terrorism forces, the police are used to reduce the rate of civilian casualties and protect people's lives.Here, we use the agent-based model to explore crowd dynamics of mass shooting, which facilitates outcomes prediction and risk management, to possibly reduce the social cost.
For the basic agent-based model, we take two classes of agents, such as shooters (killers) and civilians [8], into considerations, based on which we build and back-calculate the dynamic process of the mass shooting.However, the resisting force toward those evil killers should be considered as well.For the society, the policemen system is created to fight against the anti-social behaviors [9].One of key decisive features of policemen is the authority to use force to maintain public order in the execution of their duties [10].In most countries, the policemen are authorized to use legislative force to attack evil criminals and protect civilians.When the policemen are taken as the third class of agents, the crowd dynamics may become different.They play three roles: (a) Fighting against killers (The major probability).The shooting of policemen is the final resort to save lives of civilians and themselves.Fyfe [11] divided the shooting behaviors of policemen into "elective" and "non-elective" shootings [11].In reality, common situations are as follows: the exposure to violence for policemen and civilians [12], the killers carrying weapons (knives or guns) [13].Meanwhile, there is also individual bias [14], such as: the police are more likely to shoot young people [15] and the colored people [16,17], and the shooting propensity of the male policemen are lower [18]; (b) Shooting at civilians (The minor probability).For extreme cases, the civilians may be hurt by the shooting from policemen by mistakes.Since the beginning of the police system, the power and criteria of police shooting are controversial [19].Fyfe [19] studied the impacts of this firearms discretion policy on shooting frequencies, patterns, and consequences, finding that the most obvious result of this restriction is the reduction of police shooting and deaths [19].For example, the police (mistakenly) killing in New York is decreased obviously from 93 civilian deaths in 1971 to 8 deaths in 2010 [20].It is reported that the police shootings have caused about 1000 civilians dead at each year [21].In 2012, the US policemen have caused 55,400 casualties, and there are roughly 34 people killed or injured, for each 10,000 arrest case [22]; and (c) Shooting at colleagues (the tiny probability).For most cases, the policemen are shot by criminals or terrorists.However, they may be shot by their colleagues, at a tiny probability.In Chicago (1974)(1975)(1976)(1977)(1978), we have 187 policemen shot by killers (civilians) or sometime even their colleagues [23].Without policemen involved, the outcome can be very bad, and the police is the critical force to fight against terrorist and save lives.We take the mainstream behaviors of policemen, shooting at criminals, as the major action of policemen.
Therefore, we design main mechanism of our model as a combination of two opposite forces, the antisocial & prosocial forces.The antisocial force is used by the killers or terrorists, whose main aim is killing as many civilians as possible, and policemen use the prosocial force to protect as many civilians as possible.To protect public safety and reduce (physical & mental) damages, policemen are responsible to fight against killers (shooters), terminate ongoing crimes, and prevent it from getting worse.In addition, after killing civilians or failing to do this, the killers may incite policemen to be shot (suicide), which makes up a large proportion of recorded cases [24].Capturing essential behavioral rules of individuals, the crowd (pedestrian) dynamics should be applied as the basic (background) model.The key mechanism is the social force model.Helbing (1994) proposed this model because movements of pedestrians or population dynamics are influenced by social forces, on the basis of social psychology research [25].The social force can be applied to both normal and panic situations.In 2000, they combined the social force model with social panic [26], to create a generalized social force model, across a wide range of pedestrian density.The social force includes both attractive and repulsive forces [25].Social force model has become the key to investigate pedestrian movements [27].Most human behaviors can be modeled as crowd movements [28], which can be also regarded as collective phenomena with nonlinear dynamics [29].Generally speaking, human behaviors have two forms [30], such as cooperation and competitions (panic).Here, we deem individuals as moving particles with intelligence (agents), to observe interactions between pedestrians [31].The crowd will produce many complex forms, such as linear [32], laminar flow & turbulence [33,34], exit arch [35], blockage around obstacles [25], panic [26], and so on.The social force model can accurately describe the characteristics of pedestrians in high-density environment [36].Therefore, the use of social force model for crowd behavior can achieve more accurate simulation and research, and can reproduce the self-organization phenomenon [37].Afterward, the evolution of social force model has been revised [38], and social force model has become one of the most popular human motion models based on social force [39].Here, we use social force model as the basic mechanism for policemen, killers & civilians.
To better simulate the dynamic process and alleviate tragedies, more subtle but real situations and features have been considered: (a) Heterogeneity.Due to individual differences in biology [40] and environment science [41], the heterogeneity between individuals and groups is always greater than homogeneity [42].As an objective fact, the heterogeneity (degree) affects the emergence and changes of human behaviors [43].Therefore, it is preferred to explain social problems by the perspectives of individuals [44].According to our simulations of shooting, the heterogeneity can be understood as the different choices of escape routes and behaviors, due to physiological differences [45] (such as height, sight) and different awareness (familiarity) to local environment [44]; (b) Homogeneity.We also consider homogeneity in human behaviors of the real world.Hechathorn (1993) proposed that heterogeneity has two-sided effects, and can either promote or hinder the forming of collective actions [46].Vedeld [47] believes that homogeneity of elites enhances collective action abilities, while the heterogeneity will affect collective actions, according to the common purpose [47]; and (c) Crowding and Stampedes.Heterogeneity does not necessarily have a negative impact on collective action [48].Everyone will have diversified behaviors in the face of panic [49].Collective actions such as the shooting incident will trigger panic [50], leading to stampedes and crowding [51,52].Policemen should precisely analyze the current shooting situation and save more lives in a less fatal way, which put forward a high requirement for their ability and point out the direction for the police administration.
In this work, we use agent-based model to simulate the evolutionary dynamics of killer-policeman-civilian interactions.Previously, there are few studies on agent-based modeling of the shooting incident, especially with police involved.As a systemic modeling method with autonomous and interactive agents [53], agent-based model (ABM) can simulate their actions and reactions [39].Here, we use the Agent-Based Modeling (ABM) to simulate crowd behaviors in shooting cases, with interventions of policemen.Bridging micro-level behaviors and macro-level patterns [54], ABM can reveal the mechanism behind complex social phenomena and the effect of various factors [55].ABM is often used in multidisciplinary fields [56].It is widely used in fields of biology [57], energy supply [58], and economic analysis [59].The NetLogo software is a multi-agent cross-platform modeling and simulation environment [60], and it is one of the most widely used ABM software [61][62][63].Therefore, we use NetLogo to simulate real target case and make counterfactual inference [64], to explore effects of relevant factors and the police intervention.

The real target case
The real case of the Thousand Oaks shooting (November 7, 2018) is applied as the target case.Based on the information, the target function can be built for our agent-based model to simulate.The final task is to find the optimal solution, with the best matching degree.The detailed reports of this mass shooting can be found at the URL (https://en.wikipedia.org/wiki/Thousand_Oaks_shooting), and the locations and pictures there can be seen in Fig. 1.At the day of November 7th, 11:18 pm, one gunman, called Ian David Long, entered the Borderline bar and shot relentlessly to the crowd (civilians) there, and there were around 260 customers and employees inside of the "Borderline" bar.During the shooting process, this gunman also threw smoke bombs to civilians, which increased the panic of civilians.Inevitably, it seemed that many people will be killed or injured.Luckily enough, there were responsible policemen nearby, and they became the key counter-terrorism force.At 11:25 pm, we had two policemen entered the bar, and then fought bravely (shoot to) against this killer (Ian David Long).The tragedy was bloody: (a) Civilians.During the whole shooting process, most of them safely escaped to the outside.The killer did not take any hostages, and the process was merely continuous shooting.Inside of the bar, there were 12 civilians died, all of which were killed by the gunman or killer.Besides, when the shooting ended, we also have 19 survivors inside.They did not escape safely, but hide themselves, under the tables or covered by obstacles, to avoid bullets from the killer (mainly) or policemen; (b) Policemen.This shooting case had two stages.Before the coming of policemen, civilians inside were the direct target of the shooter.Then, when two policemen arrived, the killer began to shoot toward these two policemen.Regrettably, we have one policeman killed by the shooter, and he was shot five times more than the killer.This is because killer did not have to choose the targets but policemen aim at the one killer.Finally, two policemen jointly stopped the killing; and (c) The Killer.Before the coming of two policemen, the killer shot at civilians randomly.When they came, the killer took them as the main targets to shoot at.Finally, the shooter was also wounded, and he committed the suicide.For this real target case, 1 killer, 2 policemen, 12 civilians dead, and 260 civilians in total should be taken as objective or goals, i.e., the target function f real , for our model and simulations.

Static environment settings
The NetLogo software (6.0.4) is applied to simulate and match our real target case.Considering the location (Fig. 1A) and inside shape (Fig. 1B) of the bar, it can be considered and modeled a square space.The simulated scene size of the world (the bar where the case happened) is represented as the box in Fig. 1A, and we set maximal X and Y coordinates as 40 patches.As we are not sure about the size of the bar at the beginning, we use the parameter traversal method to find the most appropriate box size.For this case, the gunman (killer) was shooting behind the counter, and we therefore the counter is set to be located the upper right corner.From the counter (upper right corner), the gangster (killer) shot to the civilians and two policemen later as well.Because civilians (customers and waiters) inside of the bar did not carry guns, they had to choose to escape when attacked by the gangster.Under great panic generated by the sudden and bloody shooting, many civilians inside run aimless, to find possible ways to escape and avoid the shooting.Most civilians had evacuated from formal well-prepared Exits, as well as some informal pathways, such as broke the window.The number of escaped civilians is 229 ( 260-12-19), out of total 260 ones in the bar.Therefore, we set up two exits on the left and right, to represent escape routes and actions of civilians.In Fig. 1D, the dark box indicates the boundary of the shooting case, which is actually the scope of the bar where it happened.We use movable particles to refer to agents in the society, such as civilians, policemen, and the killer.Particles can only run in this box, or escape through the exit.Different classes of agents take on different shapes.The civilians are represented by dark green circles.The policemen are represented by people in blue uniforms, which is built-in shapes in NetLogo.The location of the gangster (killer) is represented by a yellow triangle with an exclamation mark, and it means dangerous agents in the society.To show the dynamic effects of shooting, the white flashed line (with the arrow) is used to indicate the directed trajectory of the bullets, from the guns to possible agents.For the policemen, the shooting behavior is captured by the directed line from policemen toward the gangster (killer), not civilians.For the killer, the shooting behavior is more complicated.The directed straight lines from him to civilians show bullet traces.Directed straight lines from him to civilians show the dynamic battles between bad and good agents.

Movable agent settings
In our agent-based dynamic system, we have three classes of agents, such as civilians, policemen, and killers (gangsters).
For the real target case, waiters and customers are all civilians, because they are not armed, with little resisting ability to the killers.On the contrary, the police with weapons are professional resisting force.Relevant settings of agents are as follows: (a) The perception range R. The perception range (radius) captures the ability of agents to perceive (see) local environment and other agents [65].Figure 2 shows both settings of homogeneous and heterogeneous perception ranges.Due to differences in terms of age, gender, time [40] and personality [45], there is always heterogeneity among individuals.Besides, the complexity of the environment further increases this heterogeneity [41,44].Under heterogeneity of R, the information is private and not shared [66].In other words, the society is stratified.Those with a larger R have better understanding of their local environment, are therefore more likely to escape safely.Here, we use the Poisson distribution (mean Standard Deviation R).In terms of other aspects, social members may be the same (or similar).Here, the homogeneity of the perception range (R) includes both spatial and temporal homogeneity [67].For some real-world cases, constant interactions between agents [68] will form the process common information (knowledge) [69].Under the homogeneity, the information is highly shared, agents have the same understanding of the environment.Comparing homogeneity and heterogeneity, the mean of perception is the same of R. When exits are within the perception range, civilians will run toward them.When civilians cannot see exits, they will run disorderly under great panic.In fact, with the progress of terrorist attacks (shooting), more and more civilians will be aware of current situation, and they will share information such as evacuation routes and exits.Therefore, we set the perception range R to increase over time, which can be seen in Eq. ( 1).Because the shooting occurred at night, the visibility was much lower.As well, the gangster threw smoke bombs insides of the bar before shooting.Hence, when the perception range is too small, the panic can spread more quickly among civilians.It is more difficult to find the exits, and they cannot escape rationally, which highly increases the probability of crowding and trampling somewhere.
(b) The life indicator Blood.For all agents (killers, policemen, & civilians), the health status of civilians can be measured by the key indicator of Blood, which is a unified concept to indicate healthy, injury, or even death of them.The Blood also refers to the strength of agents.With a higher Blood, the agent will be stronger or healthier than others.For multiple factors (such as sex, age and race), the Blood values of agents are heterogeneous.Generally speaking, we have stronger, normal, and weaker agents in society.Weaker agents can be children, women, and the elderly, which can also be also defined as soft targets [70,71].The stronger agents can be killers and soldiers.Hence, the normal distribution can be applied to capture the Blood distribution of agents.According to national census (such as in China), there are roughly one quarter (25.52%) of total population under 14 years old or over 65 years old [72].To match the proportion of vulnerable groups (25.52%), we set initial Blood values of total 260 civilians to follow the normal distribution, with the mean 100 and SD (Standard Deviation) 20.According to the density function in Eq. ( 1), we can achieve the F(x) 0.25≈25.52%,which coincides with real-world populations.Thus, this proportion of civilians (25.52%) with Blood < 86 forms the vulnerable subgroup.In our NetLogo model, we use darker color to represent those who have weaker Blood values.Policemen are often equipped with weapons and protective uniforms, and they are therefore much stronger than civilians.Similarly, with anti-social ideas in mind, they are always ready to attack civilians.Besides, to launch attacks, they often make some preparations, such as bringing guns with them, taking advantages of the terrain, and making attack plans in advance.Thus, the Blood values of policemen and killers can be set as the same levels, and they are all much higher than those of civilians.For our real target case, one policeman was killed by the shooter five times, which guides the settings of the shooting harm (gun damage) of each one bullet (the next section).
(c) The Shooting Settings.When the shooting begins, the given Blood values of agents will be reduced accordingly, and related action rules will be obeyed by agents in our agent-based system.For this case, the lethal (harm) powers of pistols (policemen) and hand-held rifles (the killer) are comparable or similar.Hence, we set the shooting harm ranges from 40 to 100 blood, i.e., the interval of [40].One fixed value will be taken for each simulation.Both killers and policemen need the time to aim at targets and update the bullets, we set them to shooting time ranges from 2 to 4 ticks.Initially, the killer just shot civilians randomly.The shooting distance affects the hitting probability [73], and, based on real target case, the shooting distance of killer is set to be 1/2 of the world.For policemen, it is 1/4 of the world, which is less than the killers, because they attack from outside to inside, they are not familiar with inside, and the killer has occupied a favorable position (counter).When two policemen arrived, the struggles between them and the killer became the main part.In Eq. ( 3), we provide a unified definition of the physical condition for all agents.As the simulation goes on, if their blood values remain unchanged, the same as the initial values, they are healthy or unharmed.The Blood of all Fig. 2 Homogeneity and heterogeneity settings of civilians' perception radius.The perception range of each agent is a circle.The picture on the left shows the homogeneity of civilians' perception range.The sensing radius of each agent is equal.Agents can perceive each other.The picture on the right shows the heterogeneity of civilians' perception range.The perception radius obeys Poisson distribution with mean R. Agents with larger perception radius have more information about environment and other pedestrians agents (policemen, civilians, and killers) will be reduced, if they have been shot.If the Blood values are decreased, agents have been hurt and they become injured.If the blood values are not positive, they die.Based on the death of one policeman caused by 5 shootings and equal-Blood assumption of policemen and killers, we define that they will die if shot, by five times or beyond.In other words, our model should make sure that agents will die after receiving five plus bullets.In this work, our priority is to calculate the death of agents, not the injury cases.For our real target case, the policeman who died was once mistakenly hit by the other policeman, which is too accidental to be considered (modeled).The civilians die, when the Blood is below zero.Definitely, this is bad situations for civilians under shooting, because they have no counterterrorism ability.During the whole process, they, under high risk, merely had two choices, either escaping to find Exits, or hiding behind obstacles inside.For the real case, we finally have 19 survivors inside when it ended.Accordingly, we terminate the simulation under two conditions: there are 19 survivors or below in the system; all the killers have died.

The mechanism of pedestrian dynamics
Usually, the attack is launched by the killer based on rational choices [74,75], and the killers have some well-prepared plans, such as the real target case applied here.Hence, the killers know more information about attack, such as when (night), where (bar), and how (gun).However, the situation became the worst for civilians, who had no idea of what is going to happen.We model the pedestrian dynamics of civilians under the shooting as follows: (a) Movements.The civilians will fall into panic [50] when suffering emergencies.So, the social force model [25] is used to simulate the crowd movement rules in panic [26].As is in Fig. 1, we first traverse the moving speed of civilians, within the range of 0.1 to 1 patch at one tick (t).This range will be narrowed further, by iterative and repeated simulations.For instance, we finally apply the speed range of 0.2 ~0.4 patch per tick.
Figure 3 shows the relevant settings of social force model [25,26] for particle movements, which should be obeyed by all civilians in the system here.For the repulsive force, civilians (pedestrians) move against walls.For Situation A, when an agent (particle) is going to hit the wall with the angle α, it will move away from the wall with the angle (1 − α) at the next tick (t + 1).For Situation B, the repulsive force also exists between pedestrians.When agents B and C encounter (on the same patch), two directions will be changed randomly; (b) Escape.For Situation C, the civilians have to find the way out, and the Exits have attractive force to civilians.However, they should see the exits first, which is determined by individual perception range.When civilians perceive the exit, they will run straight toward it, until they can escape.The particles escaped successfully are no longer threatened by shooting, and they disappear in our system.However, too many civilians running toward the same Exit may cause congestion and stampede; (c) Avoidance.Generally speaking, if too many people rush to the exit within a short period of time, it forms a self-organizing arch at the exit [35].To avoid large-scale collision and stampede at the exit, civilians will choose relatively blank areas as escape routes; (d) Collision.Under sudden attacks, the civilians fell into "escape panic" [76], and they move in an unorganized and irrational way [50].This process is prone to cause collision and stampede [51].When two moving pedestrians are on the same patch, When there is an exit in the perception radius of pedestrian D, the direction of pedestrian D is toward the exit they will cause collision damage to each other.In Table 1, We traverse the 1 ~10 range of collision damage; and (e) Death.For all agents, when blood ≤ 0, they die.In our model, dead particles cannot move or be shoot, and the gray agents represent dead ones.

The settings of police response (intervene)
Considering that the duration of each simulation is different, if we use the absolute time, ticks, to measure the response speed of the policemen, it will reduce the authenticity and randomness of our model.In the real case, the duration of the shooting incident is certain, and the police arrive the scene at a certain time.The shooter died by shooting himself, the duration of the shooting depends on the number of shots fired by the shooter.Because the duration of each simulation experiment fluctuates, using ticks to measure the time of police intervention is "absolute".While using the number of shots, we can get the "relative" time of police intervention.This setting can better reflect the police response speed of real cases.Therefore, we set the scene for the policemen to intervene after the killer (gangster) fired a certain number of shots.
The number of shootings by the gangsters increases with time.So, we can measure the time of policemen intervention by the number of shootings.In the model, we recorded the intervention time (T icks Enter ), when the police arrived at the shooting scene and the duration (T icks T otal ) of the shooting incident.The ratio of them is recorded as the response speed of the policemen in Eq. ( 4), and the golden intervention time of the police is explored as a reference (guide) for

Optimal solution outcomes
Based on mechanism settings above, we make ABM modeling and research on the dynamic process of shooting cases with police intervention.Table 1 shows initial parameter settings, and related parameters or factors (X variables) are listed.As our main concern is to explore this process and find possible ways to reduce injury and death, for both civilians and counterforce (policemen), the numbers of dead civilians (Y1) and dead policemen (Y2) are taken as the outcome indicator (Y variables).Each unique combination of parameter is deemed as one (unique) simulation.We traverse all relevant parameters in Table 1 (multiple simulations) to find optimal combination of parameters, to best match real target case (Y variables).To obtain robust results, we repeat each simulation for 100 times and take average values as the final consequence (repeated simulations).Based on key features of real target case, the target function should be construct, to be simulated or well matched.For this case, we have 1 killer, 1 policeman killed out of 2 ones, and 12 deaths out of 260 civilians.

Solving optimal solutions
The real target function of our real case should be f real f (1,2,12,260).This real target function has four values, which should be well matched by our model and simulations.
When the one killer entered the bar and started shooting, there were about 260 civilians (waiters and customers).After this gangster (killer or shooter) opened fire for a while (around 12 min), the police station nearby received the alarm message in time.Then, two policemen entered the scene and fight fiercely with the killer.After the shooting, we have 12 civilians and 1 policeman killed.Finally, the killer committed a suicide with his gun, which is not included in the death toll.After his death, in addition to the civilians who successfully escaped, there were 19 survivors in the bar.If our model holds, we can find at least one combination of parameters, which can well match our target case accurately.
Through traversal parameters, we find three combinations of optimal solutions consistent with the target Y variables.we build multiple simulated functions ( f sim ) for multiple simulations (repeated for 100 times).The difference between simulations and real target case can be calculated as the difference between simulated function between real target function and simulated functions.In Eq. ( 5), we use the ratio, , to calculate the gaps between them.The optimal combination of parameters can be solved when the difference (gap) is minimal, and we define Par( * ) as the optimal solution.We have done 35,000 simulations under different parameter combinations to find the optimal solution parameters.We run each combination of parameters 100 times, and use the average value to match the real results.Finally, we find three optimal solutions Par( * ), which satisfies the minimum condition.Three optimal solutions (Par * 1 , Par * 2 and Par * 3 ) can be shown in Table 2. Hence, we have at least three combinations of parameter to best match the data of our real target case.
The matching of three optimal solutions Based on optimal solutions (Par * 1 , Par * 2 and Par * 3 ), we can best match the real target case.Figure 4

Robustness of optimal solutions
To further verify the robustness of simulations, we also show 1000 simulations under three optimal solutions in Fig. 6: (a For the number of dead civilians, the normal distribution can be obvious.For the number of dead policemen, we have many values of 0, 1, and 2, which is why we have horizontal values in Q-Q plots.Further, we increase the number of simulations under the optimal solution to be 10,000.The results can be shown in the Table 2.

Explorative Counterfactual Inferences
Counterfactual inferences, based on optimal solutions, help us to know more information beyond real (observed) target case.Based on agent-based models, we can explore outcomes of all the related scenarios, namely strategies of agents.For strategies of killers, we explore various number and positions of killers, and they have the same number of two policemen; for policemen, we discuss the results of different numbers of policemen involved in the scene.As for the response time of the police, we also discuss the results of different response speed of the police on the shooting incident.

Strategies of killers
For strategies of killers, we discuss and compare outcomes when the killers are stranding and shooting at different positions (corners, centers, exits & random).We discuss the case of 1 ~4 shooters at each position.Because in the vast majority of real shooting attacks, the number of killers is only one [77] and 1 ~4 killers can cover most of the shooter's attack schemes.

Killers shooting at corners
For attacking plans, there can be different numbers of killers, and the positions occupied by these shooters are also diverse.Under optimal solution simulations, we obtain robust outcomes of 100 repeated simulations for all strategies in Fig. 6: (a) One killer as baseline.For the real case (fact), we have one killer shooting to civilians at the corner, which can be seen in Fig. 6C1.The death tolls of civilians, in Fig. 6A1 3 .Meanwhile, the number of dead policemen is 2 (SD 0) for all, which means that all policemen will die; and (e) Four killers at four corners.It gets worse further, if we have four killers at four corners in Fig. 6B5.The death tolls of civilians are increased further in Fig. 6A5, such as 72.4 (SD 8.55), 50.44 (SD 6.79), and 49.31 (SD 9.04).Similarly, all of the two policemen will die, which is bad news for civilians.From 3 to 4 killers, the biggest growth of civilians died is produced.We have two reasons: three killers at corners shoot more widely, and the shooting range becomes saturated with 4 killers; all of two policemen died, and civilians lose counter-terrorism force to protect them.

Killers shooting at exits
For real target case, the shooter was at the corner.In this section, we explore the situations where the killers shot at Exits.According to rational choice theory [74], the killer chooses shooting locations to maximize his purpose and interests.Therefore, the killers may block the exits and shoot right there.For our real target case, two policemen broke into the bar through the left Exit.Hence, the left corner is defined as the close Exit, for the killers, and the faraway Exit is the right Exit.The death toll of policemen is zero under three optimal solutions, because they fight right there, at the close Exit; (b) One killer at faraway Exit.For this situation, the killer shot at the right corner, and two policemen enter the bar through the left corner.(SD 13.23).Two policemen entered the bar from the left Exit, and all of them will die, as the death is 1.98 (SD 0.14), 2.00 (SD 0) and 1.99 (SD 0.1) under three optimal solutions; (g) One killer at close Exit and two killers at faraway Exit.Under same other conditions, this is slightly "better" for both civilians and policemen, because the counter-terrorism effect is better when killers stand and shoot at close Exit.We have 72.57(SD 20.12), 52.95 (SD 14.02) & 52.14 (SD 15.28) deaths of civilians, and 1.97 (SD 0.17), 1.96 (SD 0.24) & 1.97 (SD 0.17) deaths of policemen; and (h) four killers equally at two Exits.For two killers at left Exit and two at right Exit, it is worse further for civilians.We have 107.84(SD 6.89), 82.58 (SD 7.95) and 74.11 (SD 8.81) deaths of civilians.As well, two policemen have no chance to live, and the death is definitely 2 (SD 0).

Killers shooting in the field
Besides of shooting from Corners and Exits, the killers can also shoot in the area.The position of killers should be random, and we explore outcomes of four situations in Fig. 8: (a) One killer at random position.For one killer shooting from a random position, the deaths of civilians can be 24.03  3 .As well, the deaths of policemen also rise, such as 1.97 police deaths (SD 0.22), 1.97 police deaths (SD 0.22), and 1.97 police deaths (SD 0.17).Hence, two policemen will die, for most cases; (c) Three killers at random positions.It gets worse further as we have three killer who are shooting from random positions.There will be more deaths of civilians, such as to 90.74 (SD 13.45), 69.65 (SD 12.95) and 65.29 (SD 13.19) civilian deaths, under Par * 1 , Par * 2 , and Par * 3 .And two policemen will die, because we have 2 (SD 0), 2 (SD 0), and 1.99 (SD 0.1) policemen deaths; and (d) Four killers at random positions.The situation will become the worst, we have four killers shooting from random positions to the 260 civilians and two policemen.Figure 8 indicates that both civilians and policemen will suffer from the biggest death tolls ever.For civilians, we have 116.2(SD 12.12), 91.36 (SD 14.40) and 80.55 (SD 11.96) deaths, under three optimal solutions.Two policemen have no chance to survive, as we have 2 (SD 0) deaths under all cases.In general, the deaths are enlarged with more killers added shooting from random position toward civilians and policemen, and this change is more obvious in civilian deaths than policemen.

Killers shooting from the center
Generally speaking, the death tolls when killers shooting from the center will be higher than shooting from random positions, under the same number of killers.Based on agent-based modeling and simulations, we can infer accurate numbers of deaths: (a) One killer shooting at the center.When we have one killer shooting at the center, there are 41.44 (SD 6.94), 26.87 (SD 7.30) and 27.49 (SD 9.96) civilian deaths, under three optimal solutions.For two policemen, their death probability is higher than 50%, as we have 1.79 (SD 0.52), 1.76 (SD 0.53) and 1.77 (SD 0.51) deaths for policemen; (b) Two killers shooting at the center.Under this situation, the outcome gets worse.For civilians, we have 98.38 (SD 6.83), 73.69 (SD 6.68), and 70.48 (SD 8.43) deaths.For policemen, the death probability of two policemen is 100%, as we have 2 (SD 0) deaths under three optimal solutions; (c) Three killers shooting at the center.For this situation, it gets worse further, as we have 128.22 (SD 7.21), 106.48 (SD 7.58), and 94.25 (SD 7.67) deaths of civilians.For two policemen, all of them will die as well, because of we have 2 (SD 0) deaths for all cases; and (d) Four killers shooting at the center.It is the worst as we have four killers, shooting to civilians from the center.For civilians, we have 148.59(SD 6.36), 128.94 (SD 7.35), and 115.09 (SD 7.91) deaths.For two policemen, they will die with the probability of 100%, as the death number is 2 (SD 0) under three optimal solutions.Shooting from the center, the valid killing angle is 360°, while it is usually less than 360°for shooting from random positions.Hence, killers at the center will produce the worst outcome.

Strategies of policemen (the counter-terrorism force)
For our real target case and its counterfactual simulations, two policemen have little chance to be all safe.At least, one policeman will be killed, and the other will be killed for most cases.Hence, we further explore all the possible strategies.For our real target case, the one killer shot at a fixed position (the counter).Therefore, we explore and compare both situations fixed positions and moving positions for this killer (Fig. 9).

The size effect of policemen
It is commonly believed that more policemen involved will attack more killers and protect more civilians.As well, it is difficulty to calculate or estimate this whole mapping, with a higher accuracy, in reality.However, this can be obtained by counter-factual inference or simulations, based on optimal solutions.According to real target case, we set one killer for all and let the number of policemen grow from 1 to 10.We plot the high-definition trends under two conditions: (A) Killers shooting at fixed positions.For subfigures A, B & C, we depict the mean outcomes of three optimal solutions, as the overall trends.It includes: (a) The death of civilians.For the general pattern in Fig. 10A, the averaged death toll of civilians (for three optimal solutions) declines from 11.98 to 10.51, as the number of policemen increase from 1 to 10.For details of three optimal solutions, it declined from {12.01 (SD 4.06), 12.56 (SD 4.69), 12.10 (SD 7.13)} with 1 policeman, to {10.59 (SD 3.08), 10.70 (SD 4.00), 10.23 (SD 5.74)} with 10 policemen.Hence, more policemen involved will better protect the lives of civilians; (b) The death of policemen.For the death of policemen, the two-stage pattern can be witnessed.This nonlinear effect can be seen in Fig. 10B, with a threshold of about 5 policemen.When the number grows from 1 to 5, the mean value of dead policemen also increases from 0.75 to 1.82.For details of three optimal solutions, it grows from {0.43 (SD 0.50), 0.68(SD 0.47), 0.45(SD 0.50)} with 1 policeman, to {1.60(SD 0.94), 2.09(SD 1.09), 1.77(SD 0.98)} with 5 policemen, under three optimal solutions.However, as the number of policemen involved grows from 6 to 10, the deaths of policemen increase slowly and then decrease by little, between 1.83 and 2.04.The highest mean value is 2.04 (8 policemen).For details of three optimal solutions, there are 1.69 (SD 1.14), 2.46 (SD 1.51) and 1.98 (SD 1.15) police deaths.Statistically speaking, there are no differences.Hence, the shifting point is 5 policemen.Before 5 policemen, the counter-terrorism force of 1, 2, 3 and even 4 policemen are not enough to counter killers, and the social cost (deaths of civilians and policemen) are still substantial.However, if we have more than 5 policemen, the social cost can be well controlled; and (c) The death of killers.For killers, the death probability, in Fig. 10C, increases all the time as the number of policemen grows from 1 to 10.For the mean values, we have zero killers killed, if there are merely 1 policeman; the probability increases into 0.33%, if we add more one policeman; then, it will be 6.67% under three policemen; if we have 6 policemen, it is 30.67%, which means that one of these three killers will be dead; it is 57.33% if we have 10 policemen, which mean that the possibility of killer deaths exceeded half.For details of three optimal solutions, it increased sharply from {0 (SD 0), 0 (SD 0), 0 (SD 0)} with 1 policeman, to {0.47 (SD 0.5), 0.67 (SD 0.47), 0.58 (SD 0.49)} with 10 policemen.In Fig. 10C, the general pattern is linear.whose peak is not obvious, we can see a clear nonlinear pattern with one peak, as the number of policemen grows from 1 to 10.The peak is reached as we have 3 policemen.Before the peak, the death of civilians increases as the number grows from 0.89 (SD 0.75) to 1.76 (SD 1.37);Then, it declines from 1.69 (4 policemen) to 0.78 (10 policemen).When we do not have enough counterforce (less than 3 policemen), it is quite danger for them to fight against the killers.As we have enough counterforce (more than 3 policemen), the death of them will decline.Comparing Figs.11B and  10B, there is no significant difference for the death of policemen, no matter killers can move or not; and (c) The death of killers.For the general trend in Fig. 11C, the death probability of this one killer will increase as the size of policemen grows from 1 to 10.The death probability of the killer increases sharply from 9% (1 policeman) to 77% (5 policemen), and then gradually from 86.67% (6 policemen) to 98.67% (10 policemen).Comparing Figs.11C and 10C, the death probability is much lower if this killer does not move, because moving increases the chance to be killed by policemen while hiding behind the counter (not moving) does not.The death probability is 61% with 4 policemen involved, which indicates that the counterforce should be 3 times of (each) one terrorist (killer), at least.Generally, the moving of the killer increases the risk of civilians and the killer himself.

Response time effects of policemen
The response time of the counterforce (policemen) also matters a lot.Hence, we explore all possible outcomes based on different response time, which can be also deemed as the strategy of policemen.As mentioned earlier, we set the police to arrive after the shooting begins for a while, which is defined as the response time.We deem the response time to be the number of shootings, which is defined by our model.We explore every per 10 shots as a unit of measurement between 10 and 100 shots.The shooting times (the number of bullets fired) is roughly in line with the time eclipsed.Hence, we use both absolute shooting T icks and percentiles (see Fig. 12) to denote the response time of policemen.In this section, we simulate two policemen, because we have two of them in real target case.We explore and compare two situations: For this killer shooting from a fixed position, the number of dead civilians will grow as the response time of policemen increases, which coincides with the common sense because the later reaction of them leads to more civilians to be killed.This trend is linear and milder; (b) The death of policemen.As the response time of policemen grows, the death number of themselves will decline.This is because the later they arrive, the less chance to fight with the killer, and therefore the less death of policemen.This trend is linear and the negative slope is substantial.For these two policemen, they will be dead for most cases, if they arrive the bar when 10 shots have been made.The death probability declines to 52.5% (1.05/2) if they arrive after 50 shots made by the killer.For most cases, we have one policeman alive and the other will be killed.After 70 shots of the killer, the death probability declines further to 0.3, and we will have 2 of them alive for most cases (simulations); and (c) The death of killers.The trend is nonlinear, and the death probability of the killer is much lower for all cases.The peak death probability, which are 1.57%, of the killer will be reached, if two policemen arrive right after 10 shots.As the killer has occupied a favorable position (behind the counter), it is difficult for two policemen to kill them, during the whole shooting process.Hence, for policemen, the larger response time or slower response brings more death of civilians and less death of themselves.(B) Killers shooting while moving around.Figure 13 shows the trend of response time of two policemen, when the shooter can move.We explore: (a) The death of civilians.The trend in Fig. 13A is nonlinear.For policemen, there seems to be some optimal response time, under which the minimal death of civilians can be achieved.As the response time grow from 10 to 30 shots, the death toll of civilians declines from 18.89 to 14.47.Then, it grows from 16.80 (40 shots) to 26.41 (100 shots).Hence, the optimal response time is 30 shots (101.34 ticks), which is the 40.75% of the whole shooting process.Compared to Fig. 12A, the death of civilian is much higher when the shooter can move; (b) The death of policemen.The trend in Fig. 13B is also nonlinear, which implies that the moving mechanism of the killer brings much more chaos to the system.The minimal death of policemen can be reached at the 40 th shot, and it is 1.21.As the response time grows from 10 to 40 shots, the death of policemen declines from 1.83 to 1.21.It then declines further from 1.41 to 0.29, as the response time grows from 50 to 100 shots.Therefore, the optimal response time is 40 shots, which is 52.16% of the total duration; and (c) The death of the killer.The death probability for the killer is also nonlinear, but the peak is obvious.As the response time grows from 10 to 40 shots, the death probability increases from 10.33% to37.33%.As the response time grows from 40 to 100 shots, it decreases from 37.33% to 11.67%.Hence, the timing of 40 shots seems to be the optimal response time.The response time always exist, because the policemen are not able to be there We simulated each parameter combination 100 times as early as the shooters.Hence, the optimal response time is valuable for emergency response, and it can be obtained or calculated by our simulations.Generally speaking, the optimal response time, for policemen, is between 30 and 40 shots.Comparing Figs. 12 and 13, the moving of the shooter increases death probabilities of all agents.

Conclusions and discussion
Agent-based models of three classes of agents have been used to model the crowd dynamics of civilians under shooting.Besides interactions of killers and the counterterrorism force of policemen has been applied to explore the effects of their behaviors.Especially, we model both the killing force (of killers) and counterforce (of policemen) to model evolutionary dynamics of the crowd under shooting, which is closer to reality.Given the real target case, simulations of our model have well matched this reality, based on which three optimal solutions have been obtained (see Table 3).The optimal solutions provide detailed laws and regulations for understanding the crowd dynamics under shooting.Based on agent-based model and optimal solutions, several key knowledges can be found, which supports better and smart public polices of emergency responses.The real outcomes of deaths for civilians, policemen and the killers can be well matched by simulations under optimal solutions.We can achieve both validity and robustness of our agent-based modeling.Thus, key behavioral mechanism of individuals has been captured or back-calculated by our model.
According to our agent-based model and optimal solutions, we can accurately estimate effects of several factors with significant societal implications, by counterfactual inferences.We deem values of factors as different strategies, for civilians, policemen, and killers.For strategies of killers, we explore different sizes, positions and moving patterns of the killers.For the size of killers, the pattern is clear.As the number of terrorists grows, the deaths of both civilians and policemen will be increased.For the positions, the death toll be the highest when the killers are at the center, because the shooting angel is 360°.For random positions, the death toll is the second largest, as the shooting angel is close to 360°.Then, the death is less further if killers are at the Exits, as the shooting angel is close to 180°.For positions of corners, the death toll is the lowest, because this angel is around 90°.For public polices, we should set police stations near to the Exits, because the policemen will kill more killers if they are at the same Exits.Compared to non-moving, the death will be much higher if the killers are moving and shooting.Hence, the killers should be forced or suppressed to be at fixed locations, by the policemen.
For strategies of policemen, we explore the size, locations, and response time.As well, we simulate strategy interactions for policemen and killers.For killers shooting at fixed positions, as the number of policemen increase (1 to 10), the death of civilians first declines and then stops decreasing, the death of policemen first increase and then remains stable, and the death probability increases linearly.For killers shooting while moving, the patterns for the deaths of civilians and policemen are similar.However, the peak effects can be witness as for the death of policemen.Therefore, we can solve optimal size of policemen, according to strategies of killers.The optimal size is 4 to 5 policemen if the killer shots at fixed positions, and we need more if the killers are shooting while moving.If we have 7 plus policemen, the death probability of the killer will be 90.33% and beyond.For the response time of policemen, the pattern is clear as the killer shots at fixed positions.As the response time increases, the death of civilians increases gradually, the death of policemen declines gradually, and we can see the peak of death probability for the killer.Hence, we obtain optimal response time (for policemen).For the killer shooting at fixed positions, the police should arrive as early as possible, to reduce death and injury.For the killer shooting while moving, the optimal arriving time is 30 to 40 shots (bullets) of the killer.

Fig. 1
Fig. 1 The real scene of the case and NetLogo Modeling Interface.The picture on the left above shows the location of the bar where the shooting took place.The laser in the picture in the middle above is used to illustrate the bullet track of the front stairs.The picture above on the

Fig. 3
Fig.3The application of social forces in pedestrian dynamics.Scenes (a) and (b) show the repulsive force.Among them, the scene (a) represents the repulsive force of the wall on pedestrians.When pedestrian A touches the wall with angle α, he or she will stay away from the wall with angle α at the next tick; the scene (b) shows the repulsive shows the outcomes of 100 simulations, which have achieved the best matching degree: (a) the number of dead civilians.In real target case, the death is 12 civilians.Under three optimal solutions Par * 1 , Par * 2 and Par * 3 , we have mean values of 11.89 ≈ 12, 11.89 ≈ 12, and 12.01 ≈ 12, which indicates the 100% matching.The SD of death tolls under three combinations of optimal solutions are 3.81, 3.73 and 6.02, less than the mean value; (b) the number of dead policemen.In reality, we have one policeman killed, and Par * 1 , Par * 2 and Par * 3 have mean values of 0.94 ≈ 1, 1.18 ≈ 1, and 0.96 ≈ 1 killed, which is a 100% matching; The SD of death numbers of policemen under three combinations of optimal solutions were 0.73, 0.70 and 0.69 respectively; and (c) the distribution.We use the Q-Q normal plot to check the normality of 100 simulations.Six Q-Q normal plots, at the bottom of Fig. 5, check the normality of civilian and police death tolls, under Par * 1 , Par * 2 and Par * 3 , respectively.If we drop extreme values, the normality of civilian and police death tolls, under Par * 1 , Par * 2 and Par * 3 , can be supported.For the death number of policemen, we have many 0, 1, 2 values in simulations.Hence, the straight line in the Q-Q diagram is horizontal, which does not undermine the best matching of our simulations.

Figure 7
indicates outcomes of multiple situations: (a) One killer at close Exit.The killer shot at the left Exits, and two policemen broke into through this Exit as well.The death tolls of civilians can be 15.05 (SD 3.82), 10.09 (SD 3.60), and 7.69 (SD 3.53), under Par * 1 , Par * 2 , and Par * 3 .

Fig. 7
Fig. 7 Various situations of killers at Exits.The dark blue column shows the result under Par * 1 .The gray blue column shows the result under Par * 2 .The yellow column shows the result under Par * 3 .Error bars are shown in orange.Subfigure A1-A5 at upper panel show the number of

Fig. 8
Fig. 8 The impact of different numbers of gangsters shooting at random position on the number of civilian deaths and police deaths.The dark blue column shows the result under Par * 1 .The gray blue column shows the result under Par * 2 .The yellow column shows the result under Par * 3

Fig. 9 Fig. 10
Fig. 9 The impact of different numbers of gangsters shooting in the center on the number of civilian deaths and police deaths.The dark blue column shows the result under Par * 1 .The gray blue column shows the result under Par * 2 .The yellow column shows the result under Par * 3 .

Fig. 11
Fig.11The size effects of policemen when killers can move.Subgraphs A-C show the impact of the number of police on civilian deaths, police deaths and gangster deaths, respectively.Orange dot line graph shows the average outcome of three optimal solutions.The dark blue column

Fig. 12
Fig.12 The response time effects of when gangsters shoot at fixed positions.Subgraphs A-C show the impact of the number of police on civilian deaths, police deaths and gangster deaths, respectively.Orange dot line graphs are the average of three optimal solutions.The

Fig.
Fig. The response time effects of policemen when gangsters move and shoot.Subgraphs A-C show the impact of the number of police on civilian deaths, police deaths and gangster deaths, respectively.Orange dot line graphs are the average of three optimal solutions.The dark blue

Table 1
Terminology and initial parameter settings The death of civilians has been increased, such as 20.41 (SD 4.79), 16.52 (SD 4.66), and 16.When two policemen use the left Exit while two killers shoot at the right Exit, it becomes worse for civilians and policemen.We have 43.28 (SD 12.87), 35.32 (SD 9.59), and 31.6 (SD 13.26) deaths.Compared with "Two killer at close Exit", the deaths have increased as 1.93 (SD 0.26), 1.97 (SD 0.17), 1.84 (SD 0.42) police deaths, which is similar to "Two killers at two Exits"; (f) Two killers at close Exit and one at faraway Exit.For this situation, the deaths of civilians can be 80.64 (SD 15.98), 57.49(SD 11.32), and 53

Table 3
Three optimal combinations of parameters