When making an npc combatant, it's easy obvious what to do to get a robot deathmachine by optimizing combat tactics, timing and attack types, but harder (and more interesting in a fight) to get an idiosyncratic, inpredictable enemy. What behaviors (algorithms?) are useful for creating a more organic, unconventional enemy?

Edit: My specific use case is with MMO-like enemies, e.g. World of Warcraft, although with less graphics involved. Note that that means both human and inhuman enemies (animals, monsters, etc)


6 Answers 6


There is a very interesting article on the matter on Gamasutra: Intelligent Mistakes: How to Incorporate Stupidity Into Your AI Code, by Mick West.

This article talks about a Pool game AI. When implementing such an AI, it's quite easy to make it pot a ball at each shoot. A simplistic way to make the AI less "smart" is, as suggested on other answers, to add a random factor to the calculation, making the AI miss more.

But there is two major flaws with such an approach. First, it's unpredictable. For a player playing in "Easy" mode, it's unacceptable that the AI gets "lucky". What if your random factor makes the AI do an even better shot, hitting a more valuable ball, or doing a combo? You don't know what is going to happen, and being lucky shouldn't be an option for the AI on an easy mode.

The other flaw is that the player will try to identify a pattern in the AI behaviors. And with a simple random factor, there is no pattern. But that doesn't mean the player won't see any pattern, quite the opposite, in fact. As soon as the AI gets lucky, the player will see a strategy in its behavior. In the article, the players are complaining about the AI playing a position strategy. When there's just a random factor in the angular precision.

From my point of view, after reading this eye-opening article, a non-perfect AI should never use randomization as a simplification factor. It's quite the opposite. An easier AI should be smarter, but trying to help the player.

In the article Pool game example, the best option for implementing an "easy mode" AI was in fact to remove all random factor, and to add a positioning strategy. The AI would try to hit balls in order to prepare an easy and awesome shot for the player.

This way, the player will think he got lucky. And that's what you're expecting for a game when playing it easy.

  • 1
    \$\begingroup\$ It would also be useful for the AI to remember what the player is able to take advantage of. The developers may think that he has an 'easy pot' but if he can't pot it, the case tactic should be less used by the AI. It is also beneficial, because you can train the player, remember what he can't do, and purposely exploit this every so often until he can, this way the player is neither bored, neither frustrated. \$\endgroup\$ May 30, 2011 at 8:33
  • \$\begingroup\$ While I agree with not using the randomization, I don't agree with "helping the player": that would be like cheating, only much worse because you would be lying to the player. \$\endgroup\$
    – o0'.
    May 30, 2011 at 12:05
  • \$\begingroup\$ @Lo'oris: Well, I don't see it as a lie. When the players tells the game to go easy on him, he's expecting the game to be gentle. When you're playing a game you're really good at with a friend who's just discovering it, I feel it's quite okay to give him opportunities. It makes the game more enjoyable for everybody. \$\endgroup\$
    – Tyn
    May 30, 2011 at 12:58
  • 1
    \$\begingroup\$ There is a good blog post by Shawn Hargreaves on randomization, and the ability for a human to spot patterns in randomness. This would translate ton, in this case, a player incorrectly judging the tactics of an AI player. \$\endgroup\$ May 31, 2011 at 7:29
  • 1
    \$\begingroup\$ Actually I think randomization on accuracy is a good way to go. With a real player who is not that great, sometimes he will make a mistake and hit a better ball in. \$\endgroup\$ May 31, 2011 at 16:09

The key concept is to avoid giving the NPC "perfect knowledge".

  • Randomized margin of error on any decisions or actions that involve a calculation. obvious example being aiming (ie. stormtrooper snipers). If they don't always hit you, it's more realistic.
  • Line of Sight ... if they can't see you, it can make an interesting game of cat and mouse.
  • Team tactics, depending on your type of game, enemies that adapt to the situation can be way more interesting. For example, if you're getting shot at, you wouldn't charge in blindly, you'd take cover until incoming fire lets up. Or perhaps you would feel more comfortable with rushing in if you've got team-mates nearby ... you can simulate those behaviors to make the NPCs behave as if they were alive.

I'm sure there's a ton more examples that will be given, maybe you could tell us about your game and we can get more specific :-)


One quick way to render a perfect AI fightable is to have it make unperfect decisions by adding some 'noise' to either its inputs or its outputs. By noise I mean some random factors.

Here's a small example for output:

  • Perfect algorithm yields three possible actions ranked with a score.
  • Add a random value to each score.
  • Pick best score.

Here are some ideas for input:

  • If actions are based on opponent's health, add a random factor (say +/- 10 for a 0-100 health bar) to perceived state by AI.
  • Same for rating of actions, if AI knows some attacks are stronger than others, randomly add/subtract some values there.

One obvious thing to take into consideration is the speed of the AI. In most games, AIs can react MUCH faster than humans (especially in fighting) and do apparent multitasking (very visible in RTS games). So you have to act on that, by keeping the AI a bit slow (maybe adaptively so), and limiting the amount of things it can do in a determined frame of time (ie one action each half-second).

Hope this helps, and good luck!


It's difficult to give a directly useful answer without knowing what exactly you're trying to do.

I have two things to say on the subject that might help you out.

First thing (and this is by far the most important one), if you're trying to make the enemy feel more interesting and human then your combat tactics are irrelevant. The trick to making players "believe" an enemy is alive is to use animation, sounds, and little details to imply human behavior. The perfect AI might walk around a corner, see a player, and shoot. A human AI might walk around a corner, see a player, have a surprised look on his face and shout out in alarm, and shoot. The first one seems robotic. The second one seems human. Both are using identical AI in every way, other than the insertion of the animation just before shooting (or, to keep the tactical behavior the same, during shooting).

Second, avoid randomizing. Players don't appreciate it as much as designers want to think they will. Players don't see "computer generated a 1 out of 100, followed by a 5, 3, and 4, so the error factors for the last four shots were only 1%, 5%, 3%, and 4%, and that's why you died in half a second this round." The players just see enemies that sometimes wildly miss and other times nail them repeatedly for no discernible reason, which is incredibly frustrating. Good game design is largely about building patterns that human players can observe, learn, and beat, and making the player's success based on his own judgement and skills and intuition rather than making it about whether the player got lucky. The urge to randomize comes from experience with table-top games and gambling games, both of which are incredibly different mediums than video games (and what works in one medium often does not make sense in another).


I remember at our AI course at college there was a topic about making AI more "human" and less perfect. That was many years ago so I just remember a few bullet points from the top of my mind.

  • Use "libraries of moves". If you are fighting an orc, give him say 3 combat routines that they repeat every now and then. This makes combats easier by being more predictable, which seems to be the opposite of what you want, but still makes the AI less "perfect machine" and more "noob repeating the same move over and over".
  • Suboptimize, if possible. If, as you say, your AI is based on calculating the best move, put an artificial limit on this calculation. Make the search shallower, or limit the number of steps. Instead of the best move ever, the AI will choose simply a good move instead. This may add a lot of variety to your enemies behaviour, since there are many more good than best moves.
  • Make mistakes on purpose. Instead of the best move, choose the second or third best. Or even choose a move that has bad utility. This may address your "unpredictability" point.

Of course these are just general advice that should be studied and playtested for each case, and may indeed make your AI look even more artificial than intended. However I think they are a good starting point.


I just saw this pop up and wanted to share an idea that I've used in the past.

Let's say the character has three moves and each are scored, higher score is a better move. (Other answers talk about adding noise to creating this score.)

  • Attack with a sword (30 points)
  • Fire spell (50 points)
  • Ice spell (20 points)

Sum up the total points (100)

Take the character's intelligence stat out of the max possible value for this stat (let's say 60 out of 100).

Generate a random number between 0 (or some other floor) and the intelligence ratio (0.6), multiply by the total points (100). In our example, let's say the result is 45.

Now you start subtracting the bad moves from this value until you hit zero. (Subtract in order.)

First, we consider the Ice spell, which scored a 20. 45 - 20 = 25. This is above zero, so we throw the Ice spell out.

Second, look at the Attack with a sword, worth 30 points. 25 - 30 = -5. We hit our threshold, so we choose the Attack with a sword action.

In this system, a character with low intelligence won't pick the best move. And a character with high intelligence will often pick the best move. (In this example, a character with perfect intelligence picks the best move 50% of the time.)

Adding a floor mechanism to the random number will increase the chance that better moves are selected.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .