Monday, October 29, 2012

Basic AI Systems - Pattern and Dynamic AI

A major factor in how believable the game world is, comes from the AI system. When you think about it, almost every game has AI in one form or another. Even a simple game such as Super Mario Bros. has AI,  very basic AI that follows the same pattern. Nowaways we have highly advanced AI, like the ones demonstrated in the Halo series, renowned for their AI. There are varying types of AI, they can be set patterns or they can be dynamic and changing based on the state of the game. The type of AI used is dependent on the type of game being made.

For my post about making a Basic AI Behaviour, click here

Pattern AI

At it's core, a patterned AI doesn't care about what the player is doing, it's not going to react specifically to you if you happen to be jumping, attacking, or dodging. The most they might react is if you happen to be near, it will activate their AI. This is the kind of AI that was featured a lot in games in the 90s and earlier.

The most basic versions of these come in the form of goombas in Super Mario Bros. Their AI pattern is to just walk ahead and if they run into an obstacle turn around. These enemies in particular don't care at all where you are.
Super Mario Bros - World 1-1 ~ The Goomba AI literally just walks forward

Another rather basic AI is the AI in turn based RPGs, notably Pokemon (the old games). They pretty much have no AI. Where pokemon will have a list of four moves, in most battles though they will simply use them at random, with no thought to strategy. Later games started to implement actual patterns in battles to make some good strategies but they were still mostly patterned.

Pokemon Red - The AI used to just randomly use whatever attacks where in their movelist

However they can still get more complex then that fortunately. One of my favourite examples of this kind of AI is from Megaman X on the Super Nintendo.

When encountering a boss,  the boss will use predetermined attacks and go on a set path around the boss room. They may jump from place to place, fire some attack, then go to another action. The action they are about to perform is noticeable and easy to memorize once you get the hang of it and allows a player to react easily and memorize what they will do. There may be some randomness as to what order they may do the actions, but it will always be the same. They might always fire in the same direction, jump to the same location, etc.

Megaman X - Launch Octopus Boss

The most interaction they might have with the player is that they can determine a player's position and fire a missile directly towards that location. They might also change or speed up their pattern if their life is lower. Despite these potential interactions, they are still heavily patterned and won't react dynamically or specifically to what actions you're doing.

Dynamic AI

These AI are completely mainstream now and with good reason. Player's yearn to have more realistic experiences and dynamic AI will do these on the fly. This AI is the kind that pays attention all around it's environment and to the world. It uses complex pathfinding to move around the world, interacts with other objects around to act as a team or fights against the using advanced tactics. This is the kind of AI games like Halo and Starcraft is known for.

For example in Halo, Elites usually lead a pack of grunts. They act as a unit, shooting at you and taking cover. When the elite, the grunts activate a fleeing behaviour to run away. When you throw a grenade at them they jump out of the way to try and avoid it as best they can instead of just ignoring it. They react to your actions according and don't follow a set pattern.

Halo - A quick look into the AI system

Gears of War is another good example of great AI. The enemies will act together, some providing covering fire while others flank. If you stay in one spot the AI will find a chance to get around to you. They actively pay attention to their environment and obstacles that might be in there way. This is evident in the "Horde" maps in Gears of War 2 and 3, where they will dynamically change what they are doing depending on the different maps.

Gears of War 3 - Campaign

AI for fighting games leans towards both this category and patterns. On one hand they need to react to where the opponent is at all times and figure out when they are attacking and block accordingly. On the other hand they need to perform combos and memorize the order to these in. Most fighting game AI seems to be exploitable to certain patterns though as there are only so many things they can do. Some games like Dead or Alive 5 and Soul Calibur 5 are smarter and learn what moves you do and what to block during a match. On the otherhand games like Street Fighter 4 and Marvel vs Capcom 3 use the same patterns for the most part and don't even know any combos. The difficulty merely adjusts their reactions and how often they attack and block.

Soul Calibur V - Legendary Souls mode (Hardest Mode)

What's better?

Well the answer should in theory be the dynamic AI, however patterned AI still lends itself to a lot of games. A lot of action-platformers still use patterned AI or at least a very low level dynamic AI with lots of patterns. They still fit these games because it provides the players an opportunity to learn the ins and outs of the game and learn the patterns of bosses. A lot of players find thrills in being able to memorize and fight AI that they will be able to figure out and take out.

Driving games are also a good example of patterned AI as they simply follow the route on the road over and over. They use some dynamic AI sometimes (depends on the game) but a lot of simulators have the cars following a set path to have the fastest possible time. If they get knocked off course, they simple continue to try to go back onto that path. They pay attention to nearby cars so they don't crash into them but they still follow the same pattern since this pattern (path) provides the fastest potential route.

On the otherhand games like shooters heavily require AI now. People are no longer interesting in enemies that simply stand there waiting for you to come to them and shoot them. People want enemies who take cover, react to your attacks, your position and act as a team. Same with RTS, fighting games and many other genres.  The degree that the enemies dynamically react is of course dependent on the game genre, but shooters and RTS are definitely the types of games that have some of the most dependence on changing AI.

So the answer is that dynamic AI is definetely gaining much more substance but it doesn't completely replace the good old patterned AI. Even a lot of dynamic AIs have to use patterns in some form anyways. I believe that patterned type AI won't ever fully go away and will always have a place in at least some kinds of games.

Making an AI

Now I'd like to go through how you might make a basic AI in your code. This will be a two-Part blog since the content in this one relates more to game design and the other more to game engines

Click here for Part 2

No comments:

Post a Comment