About Me

My photo

My goal is to make a difference in the world, and I think the way to do that is through games. My education is in programming and 3D animating, and I have worked in e-Learning and game development. 

Wednesday, August 16, 2017

Game AI: Non-Human Behavior Part 2

This is part 2 in my series on non-human game AI, if you missed part 1 check it out first!

In nature, survival and reproduction are the two biggest driving factors of decision-making.Let's start with survival.

Starting with the big picture view, we know that all living things require energy to live, ie. food, and organisms have evolved different techniques based on where they get their energy from. One way to break this down is to figure out whether a creature is a predator or a prey at various points in the food web.

At the top we have organisms that are always predators, and generally nothing hunts them. But moving down the chain, there are creatures hunt, but are also hunted. This is where we can see some interesting behavior trees. Just from the high level goal of "survival" these creatures will need to make decisions about which is more important - avoiding a predator or finding food. If food is plentiful, that decision is easy, but if that creature has gone a long time with out food they may take bigger and bigger risks to find food, encroaching into areas they know to be dangers.

From a design perspective, what's interesting here is we can use this information in two very distinct ways. 1. Some games, especially hunting games and some survival games, attempt highly realistic simulated environments with a balance of creatures that exist for the player to hunt. These games can use information about predator/prey relations to generate believable content. 2. Beyond realistic simulations, in any game with enemies we can regard to player as a part of the predator/prey relation. The player wants to survive, so she must defend herself from enemies either with stealth or armor or by attacking and killing the enemies first, however most games have other objectives and the player must decide how much risk they are willing to take to accomplish those objectives.

In any scenario in games that have enemies, we can decide - do we want the player to feel like a predator here, or prey? Do we want the player to feel sneaky and clever and avoid getting caught/killed, or do we want the player to feel powerful and dominant and on the hunt? Both options create interesting dynamics, and a lot of games alternate between the two to create powerful exciting experiences.

As an example, in World of Warcraft if you encounter a high-level creature too early you will probably try to avoid it because you know it's stronger than you, but once you have leveled up you might return to fight it once you know you have a chance to defeat it.

Let's design an AI for a creature that is in the middle of a predator/prey situation. I like to think of AI decision-making systems as a sort of pro-con list:

This gives us an idea of the possible behaviors the AI might take, and what some of the factors are that determine that decision. Based on our pro-con list, we know that the primary decision we want to focus on is "stay and eat" vs. "run and hide" and we know that some of the factors include how hungry they are, how prevalent the food is, how dangerous the predator is, how close the predator is, and whether or not the predator has seen them. Now we can work on prioritizing these and converting them into a decision graph (or a behavior tree or state machine, depending on your approach).

This would obviously be different for different types of creatures, and it is also a very simplified solution - it only covers one very specific decision and two possible behaviors. Generally AI will have a lot of possible behaviors and different decision factors across the spectrum of possibilities. That is really what makes AI design such a challenging area to work in.

The complexity of the AI design depends heavily on how realistic the behaviors need to be. In theHunter:Call of the Wild the designers knew that players wanted a realistic hunting experience, and that often players would spend a lot of time watching an animal before taking a shot, so the designers had to be prepared to do extensive research on how those creatures behaved to ensure a believable experience for the player.

Most games are not held to quite such high standards of realism. Creatures in Legend of Zelda do not have parallels in real life, so they have the flexibility to be weird and wonky and still be believable.

In part 3 I'm going to get into some of the stranger behavior in nature, and how we can use it as inspiration in AI design.

Image Sources:

No comments:

Post a Comment