Friday, January 13, 2012

Fear Like a Disease: Applying Epidemiology Models to Crowd Simulations in Games

This post was originally the research paper portion of my graduate capstone project. Since it's relatively long I'm also offering it as a PDF here.

1      Abstract

In many games, crowd simulations are not usually as dynamic as real crowds. By applying an epidemiologic system to the crowd model we can make it more interesting. When the “fear” attribute of an AI character in the game Remote Shepherd was treated as a transmissible virus the crowd did, in fact, become more dynamic and difficult to predict. Future extensions of this work may involve applying a similar system to AI control structures or to social phenomena other than crowds.

2      Introduction

Crowd simulation in games is generally rather simple. Usually it focuses on creating many individuals, rather than an actual crowd. By incorporating an epidemiology model that mimics how viruses and pathogens spread in biological systems we can more accurately model crowds and other social phenomena.

3      Background

3.1     Crowd Simulation

Champandard1 recommends two main techniques for creating believable crowds: creating “self-absorbed pedestrians” and “combining individual behaviors.” It gives other techniques as well, but they concern animation and steering behaviors and are not as relevant. The “Self-Absorbed Pedestrian" really appears to be what most games do. As the paper recommends, nice looking crowds can be created simply by having many individual agents with no sense of the other agents except as an obstacle to avoid. But this process does not really represent how crowds actually work. Even "combining individual behaviors" doesn't create a true crowd. Although agents have the same goal, they still act as individuals decontextualized from their environment and cohabitants except as physical obstacles. They merely become multiple “self-absorbed pedestrians,” not a crowd. Individuals do not react to the behaviors of others except to try to not bump into them.  
            Crowd simulations that do take into account changes in individual behavior while in a crowd are more common in simulations than in games. Emergency response teams and law enforcement use such simulations as training for crowd control and dealing with large masses of people.

3.2     Crowd Psychology

 “Ideas, and more particularly, emotions, become contagious. They spread through the crowd like wildfire.” – An Integrated… summarizing The Crowd by Le Bon

Reicher et al2 argue that Le Bon is incorrect in terms of the crowd causing people to revert to their lizard brain and lose all sense of morality and self-control. They state that they disagree with the contagion theory, but seem to support it. It appears they disagree with the idea that the contagion theory works only to spread violence and chaos. In fact, they seem to rely on the contagion theory to explain why treating a crowd as a singular, belligerent entity can be dangerous, and why treating them as sub-crowds or even individuals (breaking the contagion) helps.

            Reicher3 writes that Le Bon attaches many implications to his contagion theory; mainly, the spread of emotions and ideas in a crowd makes the crowd mindless and any ideas that spring from it, or are put forth by it, meaningless. Le Bon uses this reasoning to effectively dismiss any kind of mass protests or dissent, because anything a crowd issues must be meaningless drivel, since the crowd is mindless and incapable of reason. He also uses it to promote violent oppression of crowds and protests, since the crowd is incapable of reason the only thing it must understand is harsh punishment.

“…but the existence of such beliefs [in imminent danger] among participants in some cases of troop flight has been questioned. For instance, Marshal (1947) states that ‘… (T)roops (sic) will always run if they see others running and do not understand why’” – Understanding …

Mawson4 states that flight is not actually a common response to disaster or perceived danger, even in crowd situations. Rather the more common reaction is to seek out familiar places or conspecifics, known as affiliation, and perhaps afterward engage in flight. This is known as attachment behavior. According to Mawson, precipitating conditions for mass flight include “the appearance of new types of weapon on the battlefield, explosions”. To apply the concept to Remote Shepherd, a gunshot might precipitate flight rather than attachment behavior. Although this behavior has implications for AI reactions to spreading fear, it does not imply anything about the actual spreading of the fear. It fortunately does not change how our AI react, as many of our NPCs are in the area alone, away from any familiar conspecifics. Thus, the expected reaction from a crowd of people in fear with no familiar conspecifics would be to flee the area. In addition, any NPCs designed to be grouped will already be near each other, meaning that they can skip the affiliation step and go right to flight.

4      Hypothesis

Much crowd simulation in the field of video games has been greatly simplified to simultaneous simulation of many individual agents. They may react to the physical presence of another agent as an obstacle to avoid, but they rarely react to the behaviors of those around them. By incorporating aspects of epidemiology, we can create more realistic, dynamic and unpredictable crowd simulations for games.

5      Experiments/Evaluation Methodology

My graduate project, Remote Shepherd, applied an epidemiology model to crowd behaviors. A “fear” property of AI agents was treated as a virus and could be passed to other agents by means of physical proximity. Properties treated as such can be called “pathogen properties.” Similar to viruses, each pathogen property has a virulence attribute, or an ease with which it may transmit.
            Considering the game deals with unseen snipers in a city park, the team decided to apply the epidemiology model to a “fear” property on agents. The fear property controls if the agents flee the area or continue their normal business. In this case virulence modeled how apparent an agent’s expression of fear was. An agent that merely walks swiftly to an exit when frightened is less likely to cause a panic/epidemic than an agent who runs screaming with their arms over their head.
            An agent would only transmit fear to another if their own fear attribute exceeded a certain threshold, the point at which they let their fear control their behaviors. Instead of transmitting all of an agent’s fear to another, a small percentage amount is added to the receiving agent’s fear attribute. The physical distance required to transmit fear is determined by the virulence of the transmitting agent. A higher virulence (more expressive panic) can transmit over a greater distance than a lower virulence. When the fear transmits, the direction in which the agent is fleeing is also transmitted. Each agent keeps track of other agents from whom they have recently received fear from. Combined with partial transmission, this process allows the system to differentiate between a single person panicking and many people panicking in terms of how much the virus spreads.
            The system also made it easy to have certain objects in game become “fear emitters”. Upon the death of an NPC, they were left in the park, and their fear attribute was set above their panic threshold. The dead NPC could only transmit fear to any other agent that happened upon the body.
            I also implemented the same system in a separate rumor spread simulation. In this case, the virus was a rumor or piece of gossip, while the virulence was a measure of how much the transmitter believed the rumor. A third property of susceptibility was used on the receiving agent, this property quantified both the gullibility of the receiving agent and the interest they had in the rumor topic.  The rumor project modeled a crowd of RTS style AI agents, each entering the area, collecting a resource, returning to a storehouse, going to a pub when tired, and repeating.

6      Results

With the epidemiology mode turned on, the AI indeed became more dynamic and less immediately predictable in Remote Shepherd. Without the epidemiology model the crowd was rather easy to control. Agents could be kept away from an area by killing someone to setup a fear emitter, an entity that constantly emits a “fear” pathogen at high levels. There would be little to no effect on the crowd on the other side of the park.
            With the epidemiology system active, the effects of fear emitters became harder to predict and more widespread. Agents infected by the emitter would flee and possibly infect others on their way out of the park. A well (or carelessly, depending on the player's goal) placed dead body could easily cause panic and the flight of many agents, even those passably far from the body.  The idea of using dead bodies as fear emitters sparked other ideas for fear emitters. For example, instead of fleeing when panicked, agents could hide somewhere, warning passers-by about the danger.

Top-down view of the epidemiology model prototype. The blue dots circled in red are infected. The program arrived at this state starting with only three infected agents.
            The epidemiology model also had another side-effect that, although realistic, was occasionally frustrating when it came to keeping the population of the area stable. Remote Shepherd uses two-way spawn points: subway stations, side streets, perimeter paths, etc. Agents fleeing towards a spawn point would sometimes infect agents that had just recently spawned from there, causing them to almost immediately turn around and leave. Occasionally this problem would happen many times rapidly, causing a dip in the active population of the park. Eventually, the number of active panicking agents would decrease to near zero, and the park would return to normalcy until it happened again.
            In both Remote Shepherd and the Rumor Project certain areas of the level became hot zones for the virus propagation. In Remote Shepherd, the area of the park with benches became a hot zone. Besides being the only place for agents to go to sit, they tended to spend a greater amount of time in the area. Often the mass panic would start in the bench area, even if the carrier became infected in another area. In the Rumor Project the hot zone was the pub. Agents were less virulent when working, and the pub was the only one in the area. The pub was where all agents went to rest and often housed large numbers of them. Rumors often were only sporadically believed until the believers visited the pub, at which point the number of agents believing the rumor rose drastically.

7      Conclusions

Developing an epidemiology model to treat given properties and attributes as viruses is a very simple task and can change AI crowd behaviors drastically, which in certain games can change gameplay drastically. Certainly in Remote Shepherd, which is primarily about watching a crowd of people, it changed the game. It can create both new strategies for players to employ as well as new pitfalls for them to avoid.

8      Future Work

The next step is to apply the system to AI behavioral models, such as behavior trees and finite state machines. Treating behavior nodes and states, or even entire state machines or tree branches as transmissible viruses could allow the modeling of mimetic behaviors. It could also be a component of a system that allows AI agents to teach one another or learn through observation.
            Further work could be done only transmitting attributes too. One planned feature cut from Remote Shepherd was curiosity being transmissible. Instead of fear and a flee direction being transmitted, curiosity and a look-at direction would be treated as viruses.

9      References

1.      Champandard, Alex J. Simulating Crowd Dynamics: Flow Lanes and Character Animation. Retrieved March 18, 2011, from
2.      Reicher, Stephen, Clifford Stott, Patrick Cronin and Otto Adang. An Integrated Approach to Crowd Psychology and Public Order Policing, Policing: An International Journal of Police Strategies and Management, 27 (4). Retrieved March 18, 2011, from Emerald: Research You Can Use:
3.      Reicher, Stephen. The Psychology of Crowd Dynamics. Retrieved March 18, 2011, from Christian-Albrechts-Unversität zu Kiel:
4.      Mawson, Anthony R. Understanding Mass Panic and Other Collective Responses to Threat and Disaster, Psychiatry 68 (2) Retrieved March 18, 2011, from University of Virginia School of Medicine:

No comments:

Post a Comment