In this blog post, we’ll explore the various technologies used for AI in games, how they work, and the role AI plays in the gaming industry.
Why AI Is Important in Games
Most games feature opponents that players either compete against or cooperate with. While these opponents are sometimes played by other players, they are often controlled by artificial intelligence (AI). Notable examples of AI that have demonstrated abilities surpassing those of humans include AlphaGo and Deep Blue. However, if AI in games always possessed only overwhelming capabilities, it would be difficult to enjoy the games. This is because people derive the greatest enjoyment from competing against opponents of similar skill levels. Furthermore, while graphics and hardware performance were once the key factors determining a game’s immersiveness, today the role of AI in implementing natural and realistic behavior has become increasingly important.
What technologies are used to create game AI that can compete at a level comparable to humans? One of the most widely used technologies is the “FSM (Finite State Machine)”.
FSM and the Control of Game Character Behavior
An FSM is a method of representing the behavior of NPCs (Non-Player Characters) or managing the game world using a finite number of states. A state is the basic unit of behavior processing, and each state transitions to another state based on specific conditions. Because its structure is simple, easy to understand, and relatively straightforward to implement, it has been used in various games for a long time.
However, it has the drawback that behavior patterns can be easily predicted when playing the game repeatedly. To address this issue, a Hierarchical FSM is sometimes used when the number of states increases, allowing states to be organized hierarchically. Additionally, a Fuzzy FSM enables characters to choose different actions even in the same situation, thereby reducing predictability and providing a more natural gameplay experience.
In games, situations frequently arise where characters must find the optimal path to a destination based on commands issued by the player. A widely used technique in such cases is the “A’ algorithm.” The A’ algorithm finds the optimal path by efficiently narrowing the search range based on the estimated cost to the destination. While it has the advantage of allowing heuristics tailored to various map environments, it is often used in conjunction with other pathfinding techniques rather than on its own when the game environment changes significantly in real time.
Decision Trees and Team AI
A “decision tree” is a structure that represents various conditions and the corresponding decision-making process in a tree-like format. It allows for the visual representation of the decision-making process based on various conditions and is used in games to efficiently implement logical behavior plans for NPCs. In particular, it is useful during the game development process because it allows behavior to be adjusted simply by modifying external data, without the need to directly modify the code.
“Team AI” is a technology that has advanced significantly as the number of games emphasizing teamwork has increased. It involves efficiently controlling a group composed of multiple team members under a single AI “commander,” with key elements including team deployment, strategic movement, and role allocation. Generally, the structure consists of setting the overall team objective at the strategic level, formulating a plan to achieve that objective at the team level, and controlling each character’s behavior rules at the individual level.
“LOD AI (Level of Detail AI)” is a technology that applies complex AI to characters currently visible to the player and simpler algorithms to characters off-screen. This allows for a natural gameplay experience while maintaining the game’s performance.
Flocking and Life-Mimicking AI
“Flocking” is a technology that mimics the collective movement of multiple entities, such as flocks of birds or schools of fish. The entities subject to flocking are called “boids”, and five principles are generally applied to implement natural collective behavior.
The first is “Separation.” Each boid maintains an appropriate distance from surrounding entities to prevent collisions.
The second is “Alignment.” By adjusting movement to match the average direction and speed of surrounding boids, the movement of the entire group is made to appear natural.
The third is “Cohesion.” This principle causes the Boids to move toward a central direction so that they form a single group rather than scattering.
The fourth is “Avoidance.” This principle involves adjusting the direction of movement to avoid collisions with obstacles or other objects.
The last is “Goal Seeking.” This rule ensures that the group moves toward a pre-set destination.
“Artificial Life” is a field that studies the general principles of life by replicating the characteristics of living organisms in a computer environment. In game development, it has long been studied to implement characteristics such as adaptability and “emergence.” Emergence refers to the phenomenon where a characteristic that did not exist in individual elements appears anew through the interactions of the entire group.
In games, these characteristics can be leveraged to create more unpredictable behavior. While their use was limited in the early days, they garnered significant attention as they were applied in various forms in games such as the “The Sims” series. Recently, as these concepts have been combined with reinforcement learning and generative AI technologies, they are evolving toward the implementation of more natural and autonomous NPC behavior.
The Use of Neural Networks and Genetic Algorithms
The next technology we’ll introduce is the “neural network.” A neural network is a structure modeled after the human nervous system, in which numerous artificial neurons are connected to learn patterns from input data and produce outputs based on those results. In the past, it was primarily used in conjunction with supervised learning and backpropagation algorithms; today, various neural network architectures based on deep learning are being applied to game AI.
Neural networks can be used to learn from gameplay data to generate more natural behavior or analyze an opponent’s strategy, and they are employed in various fields such as NPC behavior generation, game balance tuning, and adaptive difficulty implementation.
A “genetic algorithm” is an optimization technique that mimics the principles of biological evolution. It involves generating a variety of individuals and then iteratively evolving them by passing the high-performing ones on to the next generation. This method can be used even when the search space is very large or the problem is difficult to define mathematically, and it is particularly effective for problems that do not necessarily require finding a single optimal solution.
However, it has the limitation that if the structure of the game or characters changes significantly, the representation of the chromosomes must also be modified; consequently, there has been a recent increase in cases where it is used in conjunction with other optimization techniques or machine learning.
Artificial intelligence technology in games can be broadly categorized into two types: those that mimic living organisms and those that do not. Considering that intelligence is one of the most important characteristics of living organisms, the biomimetic approach can be viewed as one of the most effective methods for implementing artificial intelligence. Such technology is widely used not only in games but also in various industries, including autonomous driving, robotics, logistics, healthcare, and manufacturing.
Furthermore, the games we enjoy on a daily basis serve as important testing grounds for researching and validating AI technology. Recently, with generative AI and large language models being applied to generate NPC dialogue and behavior, in-game AI is evolving in a more realistic and proactive direction. In games, we encounter AI as both enemies and allies. As such, AI is much closer to us than we might think, and it will continue to play an increasingly important role across various fields in the future.