Gameplay is all about decisions. Designers offer interesting choices in their levels which in turn causes the player to make a decision. In a shooter, the placement of things such as weapons or ammo elicits the decision by the player to risk their safety to get an advantage over their opponent or the decision on whether they must conserve their shots or freely lay down a shower of bullets on their enemies.
This idea of interesting decisions is what players enjoy about games and gives them a feeling of accomplishment when they have made the right decision or an even greater sense of triumph when the decision leads to even more meaningful decisions. Even when it is not the player making the decision but merely observing other players or NPCs in the environment making choices, it still leaves people with a sense of wonderment and a more solid grounding in the world the designer is trying to create. Think of how many times you’ve seen an enemy in a game look broken due to bad AI. Granted this makes it easy for the player to get an advantage on the enemy but at the same time it breaks down the illusion of the game world. The suspension of disbelief is broken and the player’s experience is lessened.
AI can never be perfect, nor would we really want it to be. While seeing huge imperfections in a system breaks the player’s immersion, so does a robotic, systematic pattern. Human players have imperfections or do things erratically so we would expect our AI NPCs to mimic some of that same level of pattern differentiation.
When working with AI in a system, we want to start off with the basics. As with any game system a lot of complexity at the start also means a lot of complex bugs to work out as the system is being built. For TUG, we started prototyping the prey AI first. This AI system had the easiest set of requirements for the AI to function. Prey needed to be able to roam its environment, graze or idle and avoid danger, mainly the player. Our first prey model is the goat.
The goat’s basic AI decisions should all have a meaningful choice behind them. Deciding whether to graze or roam around is a fairly 50/50 choice. Neither decision really affects the goat’s well being but can be driven by two factors; am I hungry or am I near danger? The player represents the goat’s main threat at this stage, so adding in a check for the player’s distance provides an influence on the goat’s decisions. With this little bit of logic, the goat can begin to make more intelligent choices. Is the player near me? I should go into alert and search for the player. Is the player dangerously near me? RUN!
Hunger is the other driving influence on the goat. Adding in a hunger range on the goat influences his choices as well. Once a goat reaches certain thresholds of this hunger level, his decisions begin to drive him more towards grazing and not just the casual type of grazing but seeking out his favorite foods like crops grown by the player! Adding in this conflicting type of decision tree, the goat may now override his fear of the threat to satisfy his hunger. This type of meaningful choice makes the goat’s actions seem more real and adds a level of gameplay for the player. They can now choose to hunt the goat based on luring it toward food or find ways to prevent goats from destroying a field of crops.
So with a few control points in his decision making we’ve created the prototype for the prey. The prey can occur in certain biomes which is handled through our generation system, it can wander and graze the land, it actively searches for threats by the player and it has an insatiable hunger for player’s crops. So now what about the predator?
Well at first glance, it would seem the predator is a whole different beast from the prey. But with careful analysis, the predator is not that much different in his decision making. We want the predator to live or at least start off in certain biomes. We want the predator to actively search for food, in this case, the prey but also the player. Finally, we want the predator to, well, act like a predator once it has found its prey: stalk the prey and take it down!
So with a few tweaks to the prototyped system in place for prey, we can have the predator searching based on his own hunger meters. The more hungry, the more actively they search for food. But also we want an alert system for their decisions as well. When the player gets too close, the predator would be alerted and immediately switch to his attack phase. Finally a decision path of what to do when it is hungry and near food would need to be in place, is it stalking the prey or has it closed enough distance to switch into its attack phase.
And with that we now have two AI prototypes that benefit from the same decision trees to make a basic cast of Critters to fill out the world and add to the player’s experience. Further tweaks to the exposed controls for these systems can add variety and expand on the functionality to create new Critters in the future. So enjoy hunting goats and watch out for that sneaky predator lying in wait just behind you!
John aka (@x_nekochu_x)