StackTips
 6 minutes

Introduction to Game Artificial Intelligence

By Editorial @stacktips, On Sep 17, 2023 Blog Posts 2.2K Views

Most of the games incorporate some form of artificial intelligence (AI). For instance, developers have used AI for years to give seemingly intelligent life to countless game characters, from the ghosts in the classic arcade game PacMan to the bots in the first-person shooter Unreal, and many others in between.The huge variety of game genres and game characters necessitates a rather broad interpretation as to what is considered game AI. Indeed, this is true of AI in more traditional scientific applications as well.

Some developers consider tasks such as path finding and collision detection as part of game AI. It includes everything from simple chasing and evading, to pattern movement, to neural networks and genetic algorithms. Game AI a weak AI.

In games, we aren’t always interested in giving non-player characters human-level intellect. Perhaps we are writing code to control nonhuman creatures such as dragons, robots, or even rodents. Further, who says we always have to make non-player characters smart? Making some non-player characters dumb adds to the variety and richness of game content. Although it is true that game AI is often called upon to solve fairly complex problems, we can employ AI in attempts to give non-player characters the appearance of having different personalities, or of portraying motions or various dispositions—for example, scared, agitated, and so on.

Anything that gives the illusion of intelligence to an appropriate level, thus making the game more immersive, challenging, and, most importantly, fun, can be considered game AI.

Deterministic Versus Non Deterministic AI

Game AI techniques generally come in two flavors: deterministic and non-deterministic.

Deterministic

Deterministic behavior or performance is specified and predictable. There’s no uncertainty. An example of deterministic behavior is a simple chasing algorithm. You can explicitly code anon-player character to move toward some target point by advancing along the x and y coordinate axes until the character’s x and y coordinates coincide with the target location.

Non Deterministic

Non-deterministic behavior is the opposite of deterministic behavior. Behavior has a degree of uncertainty and is some what unpredictable (the degree of uncertainty depends on the AI method employed and how well that method is understood). An example of non-deterministic behavior is a non-player character learning to adapt to the fighting tactics of a player. Such learning could use a neural network, a Bayesian technique, or a genetic algorithm.

Deterministic AI techniques are the bread and butter of game AI. These techniques are predictable, fast, and easy to implement, understand, test, and debug.

stacktips avtar

Editorial

StackTips provides programming tutorials, how-to guides and code snippets on different programming languages.