September 13, 2009

The 3 Flavors Of Enemy Design

I hadn't really noticed it, but I seem to avoid writing about whatever sort of design I'm currently doing all day at work. The past few months are the first time in my career that I haven't been involved in designing AI or enemies, so I find myself wanting to write a few posts about that.

When deciding on a high-level design for the opponents in your game, it helps to decide first which of the 3 major groups you'd like your enemies to fall under:

1 - Enemies that follow the rules

There are many games with AI opponents that never do anything a player can't reasonably be expected to do. This type of enemy is often referred to as "bots" and used as a substitution for players in games that are multiplayer-focused.

With good enough AI scripting, it's possible to make enemies that mimic real players, with the same abilities, limitations, and even behaviors. Playing against AI is never exactly the same as playing against a player, but they can definitely feel similar enough to feel like good practice, to a point.

In this sort of game, players will feel cheated and angry if the AI does anything that they can't do themselves.
Chess, Starcraft, Madden, Unreal Tournament, Street Fighter, Poker, Battlefield 2142
When to use them:
This sort of enemy works really well as a way of easing players into the game and preparing them for matches against real human opponents. For this reason, it generally make sense to tune these enemies to be clumsier and easier to defeat than a human would be. Despite that, these enemies are generally the kind that make the most sense to have a high level of awareness.

It's also possible to make very very challenging AI settings for people who can't find a human partner that can challenge them, but chess is the only example I can think of where this is very common.

2 - Enemies that break the rules

There is a similar class of enemies for whom breaking the rules is a possibility. They tend to have most of the same abilities as a player and generally seem like players, but they will occasionally break the rules in the service of modifying difficulty.

It's certainly possible to make AI cheat to be more difficult, but good designers also make them cheat downward, which is to see start losing a little bit on purpose if they get too far ahead. This is also known as rubberbanding, a form of negative reinforcement.
Many racing games, many strategy games (most notably the Civilization series)
When to use them:
If you're thinking of your AI opponents as a replacement for other players, rather than a training tool, it might make sense to allow them to break some rules. This sort of AI design tends to focus a bit more on matching the player's ability and making sure that the game is challenging, but not too challenging. It can ensure that the player always feels they have a chance to win (or lose) right up to the end of the game.

3 - Enemies that ARE the rules

The most common type of enemy, by far, is that which operates in a completely different realm from the player. This type of enemy not only operates outside the set of game mechanics that the govern the player, but actually becomes a part of those mechanics.

Games that use this type of enemy design tend to have many different types of enemies, which vary from location to location. This enemy variation becomes a part of the game's content and level design palette.

It's also very common for games to use this sort of enemy design in boss battles, where there tends to be a puzzle to solve, a weakness to exploit, or a pattern to memorize. Unlike the previous two enemy types, this sort of opponent is not used to teach the player how to play against other players.

In the most extreme examples, the entire gameplay of a game can consist of learning how to defeat new and varied enemy types, in increasing numbers and more complex combinations.
The God of War series, the Diablo series, the Halflife series, World of Warcraft, the Zelda series (especially their boss fights), the Super Mario series, the Ninja Gaiden series, the Metroid series, almost all shoot-'em-ups, and on and on.
When to use them:
My guideline for when to use this sort of enemy is when you'd like to present players with a more reactive form of gameplay, where they change their tactics based on which enemies they are fighting.

It also works well in games that are very content-heavy (shooters, RPGs). In games like this, enemies that try to fight like players are likely to become monotonous over time, or much easier as the player figures out all of the AI's tricks and shortcomings.

Should you combine enemy types?

Generally I'd say that it only makes sense to have one kind of enemy in your game. If you've got a really good reason, it can make sense to combine them, but there aren't very many examples I can think of.

Champions Online's enemies are almost entirely the third type (totally seperate rules), except for player Nemeses, which are the first type (same rules as players). Time will tell if this was a good idea, but the rationale of using Nemeses to prepare the player for PvP seemed like a sound one, and Nemeses were already very special and seperate from all the rest of the enemies in the game.


Eolirin said...

I think a case for using multiple types of enemy ai can easily be made depending on what your gameplay is like.

An RTS/RPG hybrid where you've got a commander player could definitely benefit from a bot-like overlord moving the individual units around, but the units themselves would be better served by the third type.

Then there are things like L4D, which blur the lines a little bit. The AI director can be considered an enemy, but it's hard to say if it's type 2 or 3. It provides gameplay and doesn't have even remotely the same set of verbs as the players, but it acts more like type 2 in that it's designed to turn the challenge level up and down to match the players. Adding more complication to this is that while it's definitely arrayed against the players - it'll amp up the amount of stuff trying to kill them more and more if they continue to meet their objectives, basically, it's trying to kill them, especially when they're doing well - the players aren't really arrayed against *it*. You can't really outsmart the AI director, and you still approach combat with the same goals in mind: take as little damage and as few shots as possible while killing everything.

Yoshi and Sylvia said...

Heya Darga, nice post! Is this what u've been working on and finally have a break from it all now? I think it's great! You know, i really recommend you write a book about game design one day (I'd be first in line to get it!) cuz I think you could add that sense of great humor and flare that Anthony Bourdain of No Reservations does to his how-to-be-a-chef books/shows! (dunno if you know of him) But lots of game design books for students are repetitive or just refreshed updates of older editions... But I think with your jargon and humor, you could write a wittier and funnier book~
and hell, you could make lots of money while doing it... if you need to know publishers or whatnot, i know Roger Braunstein (friend from CMU) is currently writing a book on graphic design and my cousin is a children's book author. Anyways, keep up the great work!! I can't wait to see the gameplay in ST Online~~~! ;D

Eolirin said...

So, Mike, I uh, have some thoughts regarding this, but my first attempt at working through them exceeded the character limit ^^.

So instead of going into detail about why I think this is perhaps a better way to look at it, I'll just provide the end point, and if there's any confusion I can add more back in.

Basically, I think you should break enemy types down based on what the goal of the AI is. You'd replace type 1 with AI that's trying to beat the player at a particular action (basically, if you replaced the AI with a player, the game would continue to function, even if the AI has access to things that the player does not), type 2 with AI that's trying to modulate an experience to match the player's performance (dynamic difficulty shifting basically, but there are probably more wrinkles than just that), and type 3 is AI that's passive, basically following it's routine until it's been interrupted in some way by player action, and then returning to that state when the action ceases. Type 1 and 2 act as player replacements, though Type 1 is playing to win, and type 2 is setting things up so that the player has a particular experience, but doesn't care about victory or loss except in how it applies to that experience. Type 3 is a system mechanic, not a competitor. The fact that mmogs tend to only consist of type 3 enemies explains a lot about why the gameplay ends up the way it does when you look at it in that light. You're not fighting an enemy, you're solving a puzzle or applying a rote skill.

These end up forming a hierarchy of sorts, based on which type is at the "top", you either have type 3, with nothing else, type 1 with type 3 subordinates, or type 2 with type 1 and/or type 3 subordinates. And of course, type 1 and 2 can have no subordinates as well.

L4D's AI director would be a type 2, with type 1 and 3 subordinates (special infected and common infected, respectively. Common have no real volition, special do, and can even be replaced by players in versus).

Combining a goal based approach along with a hierarchal view also avoids worrying about asymmetry. Units in an rts are always type 3, because they have no will beyond what their commander tells them to do, regardless of whether the player has access to them or not. In fact, they're still type 3 even in a player vs player match. You can, for example, exploit unit AI in Starcraft, even if you're playing against a player; it has different qualities and weaknesses than your actual opponent.

Eolirin said...

Oh, and as a result of those changes, I think changing the numbering of type 3 to type 0 makes a lot of sense. Type 0 doesn't provide an actual enemy, Type 1 provides an enemy that's primarily trying to win, Type 2 provides a enemy that's got enough nuance and substance that it can try to impress a particular experience on the player, not just win the conflict against the player. Each step up is a step up in sophistication.

Mike Darga said...

That's a very interesting way to look at it!

Mike Darga said...

Haha the Anthony Bourdain of game design? My mom would be so proud =P

That's definitely something I'm interested in doing eventually though.

I didn't know Roger was writing a book! That's really great. I'll have to get in touch with him and see what advice he has.

Eolirin said...

Thanks Mike. :) Thinking about it in a more goal oriented manner actually stems from some other stuff you've posted too.

I'm not sure if you've said it as explicitly as this, but some of what I've taken away from reading your posts is to stay in a more goal oriented frame of mind. Method follows intent, so figure out what you're trying to do then figure out how to do it.

Once I asked myself what the point of the various types of AI was, everything else fell more into place. It became clear that cheating AI in an RTS wasn't actually trying to modulate difficulty in response to the player, but to compensate for handicaps due to limitations in AI. Making it more of a Type 1, since the intent is still player replacement.

It keeps the methods and the goals more separate.

But, really, this blog has been very helpful in evolving the way I think about things, both from reading and responding to it. I'm very grateful that you put the time you do into it. If you write a book I would absolutely buy it :)

Mike Darga said...

Well I'm glad it helped!

I definitely need to follow my own advice sometimes heh. That's one of the great things for me about writing this actually: both writing the posts and hearing feedback on them help me find the places where my thinking has holes in it.

I'm definitely one of those people who thinks out loud or by writing. As my favorite cultural studies prof used to always tell me, you often don't know what you're trying to say until you read your own first draft.

Mike Darga said...

Thanks for the kind words as well =)

Eolirin said...

I'm very much the same, so I (and the people I use as sounding boards) know how that goes. :)

out looking for gaming graphics said...

hey great blog, love the enemy info, the ones I hate the most are the ones that kick my butt when playing. =)

You have tons of great articles, ill keep reading.

thanks, Will