🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

how would you do this w/ utility based AI + influence maps ?

Started by
9 comments, last by wodinoneeye 7 years, 12 months ago

how would you do this w/ utility based AI + influence maps ?

the desired behavior:

for some reason, i must flee - i'm half dead and its time to retreat, i'm taking missile fire from an unknown origin, or maybe there's just a really tough badguy nearby i shouldn't mess with.

but the badguys have me cornered by terrain.

so instead i should turn and attack the badguys who have me cornered.

right now i'm using rule based systems, but it could all be done with a utility system and influence maps. but offhand, i'm not sure how this behavior would be handled.

influence maps would almost / never let you get cornered in the first place?

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement
You enumerate the possible actions. For each action, determine how happy you are expected to be if you take it. Pick the action that gives the highest score (even if it's a low score).

If your utility function includes a term that rewards your enemies being damaged, even if you are dead, you can get the behavior you want.
Getting cornered is not hard even with an influence map guiding movement. Consider the following scenario:

- Friendly agent A walks into a corner to dig up some treasure
- While A is digging, hostile agents B, C, D approach from outside the attention radius of A
- B, C, D encircle the escape routes from A and close in
- A is now trapped at the dig site


The general solution looks something like this:

- Use the influence map to search for a nearby spot of low threat value, i.e. someplace safe from the hostile agents
- If the lowest nearby threat value is > some threshold, disqualify the decision to flee, and revert to combat (This can be done trivially with a suitable response curve - no need to enshrine the rule in code!)
- Optionally, sample the path from A's current location to the safe spot, and test the influence map at each point. If the threat gets too high or whatnot, you can also disqualify the fleeing decision

For bonus points, integrate the influence map with the pathfinding search and increase the cost of pathing through high-threat areas. If the path cost becomes too high, assume that fleeing is impossible, and act cornered instead.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

>>

- If the lowest nearby threat value is > some threshold, disqualify the decision to flee, and revert to combat (This can be done trivially with a suitable response curve - no need to enshrine the rule in code!)
- Optionally, sample the path from A's current location to the safe spot, and test the influence map at each point. If the threat gets too high or whatnot, you can also disqualify the fleeing decision
- For bonus points, integrate the influence map with the pathfinding search and increase the cost of pathing through high-threat areas. If the path cost becomes too high, assume that fleeing is impossible, and act cornered instead.

>>

ok, so the utility system would basically choose "fight" over "flight" in the first place - using a more in-depth and complex decision making process. i get it. thanks!

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

I'd probably attempt a very simple approach to this. I'd make the utility of a flee behavior ?equal to the current danger multiplied by the probability of successfully fleeing. The probability of being able to flee successfully can be calculated by a quick look at the influence map and a pathfinder (e.g. can a route actually be plotted to a place of safety?)

The Imap system is used most often for 2 different things:

  • What is the value of the location I'm at (or a target is at)?
  • Where is the highest/lowest place in the map?

In this case, the former suggests when you should flee (by being an input into the flee decision) and the latter suggest to where you should flee if you decide to.

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!"

Also, remember the golden rule of game AI: it is far less important how intelligent or stupid your AI is compared to how fun the player thinks it is.

A very dumb AI with great animations that choreographs emotion and human-like reactions to the player is going to result in a far better game experience than a perfect intelligence that feels like a computer game.

If your AI is making a decision, it should be obvious to the player _why_ it made that decision, and it should feel to the player that the decision is what the AI _should_ have done, that the player _believes_ the AI is a character in a world and not just a computer following its programming.

As a simple example that may be relevant to your game: if you have agents with different personality traits like "Coward" or "Aggressive" that affects the decision weighting between flight-or-fight, the character should telegraph that personality as hard as possible. The Coward should tremble more, spook when it hears an animal nearby, mumble fretfully, etc. The Aggressor should stand tall and look mean, glower at any noises it hears, growl even when a friendly moves near, etc. If the personality weighting is so light that those personality traits feel overdone... your weighting is too light to be worth adding to the game. Players won't be able to tell the difference between the characters and everything will feel wooden, fake, game-y, and lacking in immersion.

Sean Middleditch – Game Systems Engineer – Join my team!

>> The Imap system is used most often for 2 different things:

  • What is the value of the location I'm at (or a target is at)?
  • Where is the highest/lowest place in the map?

In this case, the former suggests when you should flee

so that would be a threat level influence map, and the threat level is high at/near the player - thus triggering the flee (or a search for possible escape route) - right?

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Threat or proximity. I use them for 2 different things. But yes...

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!"

>> Threat or proximity. I use them for 2 different things. But yes...

i would think that for a generic util based + Imap system, you might have a number of "things" in general that you tracked, and perhaps have an Imap for each "thing", and each AI type you created would have an influence function for each "thing", with F=0 for no influence, or just those "things" it cared about being added into the calculations. and ECS sort of AI type definitions. just thinking aloud here. would be quite generic and flexible. any variable in the game could be an Imap/influence variable.
i see how it could achieve the same results as rule-based (my personal traditional approach). is it any easier? any less prone to omissions?
"cornered by badguys", vs "cornered by anybody" was the omission that prompted my O.P.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement