Advertisement

Adding some variation to AI

Started by July 27, 2014 09:58 AM
7 comments, last by Ashaman73 10 years, 3 months ago

Hello .

I have designed a simple AI for or NPCs in game. Our game is a FPS .

Enemies in our game which are NPCs act all the same in the game. I mean they follow the same algorithm . And When they are spawned simultaneously they all shoot togheter. Reload toghether and so on ...

How can I add some variation to this with an easy trick ?

Thanks in Advance

I'm surprised that they would act that similarly, for the simple reason that each one would have a separate location, which spins off to all sorts of differences. For example pathfinding, sensory differences, etc. Check the simultaneous behaviour isn't a bug, e.g. sharing common variables.

That said, pick a few configurable attributes such as aggressiveness, caution, weapon preferences, sensory sensitivity, etc. Assign (manually or randomly) each agent's attributes somewhere in that range. I don't think any one attribute would need a huge range to get interesting differences.

In practice I would say that it's not a problem because most games rarely have large simultaneous spawns. There may be multiple spawn locations, fixed patrol routes, etc set by the designer.

Advertisement

Thanks for your answer. It's not a problem in my opinion but the designer thinks this is so stupid . He just expects a BattleFiled AI from me . Maybe I can change their animation speed and also have a higher system that enemies pickup different available actions from them.

Perhaps also the world's simplest squad AI. For example there may be a set of combat actions available, such as "shoot", "flank", "charge at", etc. As each AI chooses a combat action it could lower a global (or squad) priority for performing that action.

The initial priorities may be 100 shoot, 80 charge and 50 flank. So the first NPC chooses to shoot. Shoot gets halved to 50. Second NPC chooses charge, which is now the highest priority. Charge gets halved to 40. Third NPC has an equal choice between shoot and flank, you could resolve that whichever way you want to.

Edit: Edited to remove percentages. They didn't add up to 100, so not really meaningful as percentages. ;)

Have you thought about using random numbers for delays between actions or making the choice of which action to perform next?

The simplest answer is what Lithander mentioned. By including random delays, you accelerate the chaos theory that Jeffery is getting at (that little difference will eventually expand into bigger ones). The other thing to do is weighted randoms where, after scoring actions or doing whatever it is you do to select, you pick from the top N actions either completely at random or by weighting them according to their score.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Advertisement

What behavioural similarities are considered bad isn't completely clear.

Shooting simultaneously is a consequence of starting synchronized and being able to shoot at any time. Random delays break up the synchronization, but you can experiment with obstacles, concealment and lack of targets to make every unit shoot only when it can hit: when the enemy walks into the line of fire (and simultaneous fire makes sense), when they turn a corner (one at a time), when they randomly decide to pop out of their cover (according to the stochastic criteria suggested in previous posts), etc.

Generally "doing the same thing", on the other hand, should be addressed with multiple-unit coordination. For example, an infantry platoon or the like could, among many other things that can be modeled and executed in relatively simple ways, split into two halves that cover each other's advance or spread into a very long line to minimize the effect of enemy grenades: you would have two clearly different groups even if the constituting soldiers simply walk and shoot like any other soldier.

Omae Wa Mou Shindeiru

There is a cheap trick that would solve the problem of all your synchronized enemies and would make them seem much smarter too: Limit how many agents can perform a particular task at a given time (usually to one). For instance, one agent might decide to shoot at the player while running, without taking cover. The other agents might want to do the same, but the slot is now taken, so perhaps they will run for cover instead, and provide suppressive fire once they get there. If you also keep slots for taking cover at particular spots, they will take cover in different spots. Since only one agent can run and shoot at the player at a given time, it will look as if the others are providing suppressive fire to protect the running agent, even though there is actually no coordinated plan. You can enhance the effect by playing clips at the appropriate times (e.g., "Cover me!").

This idea is not my own, but something I read years ago. Unfortunately, I don't remember where I read it.

An other way is to mark locations. Eg I mark objects which are used by NPC for a given time. Other NPCs will avoid them until they are freed again.

This could be expanded to heatmaps, where eg. used cover will produce a new heat-point, which dimished over time. NPCs will then try to utilize cool regions. This way you automatically can profit from some emergent behavior (eg many NPCs will start to flank the player, just by avoiding heat in choke points)

This topic is closed to new replies.

Advertisement