Chapter 5. Crowd Control

In this chapter, you will learn how to build large crowds into your game. Instead of having the crowd members wander freely, like we did in the previous chapter, we will control the crowds better by giving them directions on what to do. This material will be useful for a wide range of game use cases, such as planning soldier attacks by groups or directing flows of traffic in a car game.

In this chapter, you will learn about:

  • Crowd-steering behaviors
  • Using the Fame Crowd Simulation API to manage crowds
  • Exploring ANT-Op to create more goal-directed crowds

An overview of crowd control

In Chapter 4, Crowd Chaos, we looked at creating crowds using wandering behaviors, where different crowd members worked individually to travel to different points. This works well for ambient crowds, but there was no working as a group. As there was no larger group-defined behavior or director managing crowds, our previous implementations required creating and configuring character AIs individually. Defining and configuring individual AIs is fine for smaller groups, but not practical when creating much larger crowds. In the demos in this chapter, we will look at crowds that work, or at least move, as a group. Moving AI characters in groups, also called flocks, has been a popular subject in AI for many years. The most popular system is called Boids, and it was designed in the 1980s by Craig Reynolds, a renowned computer graphics and AI developer, and the basic design is used in crowd AIs in most games today. In these systems, different simple steering behaviors are defined, such as moving to a target position or following a path, as well as behaviors to not collide with other agents or align to the same direction of nearby agents.

These simple behaviors are applied to large numbers of game characters (or in the original system, Boids), and when they run together, they move as groups the way you would expect them to. These simple behavior combinations give surprisingly realistic results considering how simple the individual steering behaviors are.

Steering algorithms are simple to implement, but instead of coding something from scratch, we will use Unity plugins. The two plugins we will be focusing on, the Fame Crowd Simulation API and ANT-Op, are not general-purpose AI systems like RAIN; instead, they are focused just on crowd management. This is a popular trend in the AI world. Sometimes, instead of a large AI system, it's best to look for specific tools for specific AI tasks. Don't worry about combining multiple AI subsystems while designing the AI for your games, as this can often give you the best result.

The Fame Crowd Simulation API focuses, as you might expect, on crowds with a system design similar to Boids. It allows you to customize different values for the various steering behaviors and has a GUI interface that makes forming and directing crowds very straightforward. ANT-Op is based on simulating ants. Looking at ants might sound strange, but ant simulation is actually a popular topic in the AI world, since ants work really well as a group. Both of these plugins are useful when creating controlled crowds.

Note

More details about Craig Reynolds' original flocking and steering systems can be found in his papers online:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.160.119