Jump to content
  • Advertisement
Sign in to follow this  
Norman Barrows

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

This topic is 895 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Edited by Norman Barrows

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

>> 

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

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

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?)

Edited by Kylotan

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

>> 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?

Share this post


Link to post
Share on other sites

>> 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.
Edited by Norman Barrows

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!