dealing with a multiplicity of AI states

Started by
20 comments, last by IADaveMark 8 years, 4 months ago

Sigh.

http://www.gdcvault.com/play/1021848/Building-a-Better-Centaur-AI

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

I would approach this with a behaviour tree based approach, where at any time the AI can be attacking, resting, fleeing or idling, for example. External stimulus and weighted responses can move the AI from one state to another along clearly defined paths.

Think about it, can you rest and flee at the same time, or attack a wild animal while eating a meal at a campfire?


Think about it, can you rest and flee at the same time,

you can be fleeing, hit total fatigue and have to collapse on the ground in exhaustion, once you can stumble on, you continue fleeing, assuming you weren't killed while catching your breath. when fully fatigued, movement is reduced to 1/2 walk speed, and attacks do 1/10th damage.

you can be wandering, take missile fire, flee, then resume wandering. same for migrating.

or you may be fleeing from the closest target, take missile fire from a second unknown target, and thererfore suddenly change direction for a while (flee from incoming).

or half-dead: flee from target, but first flee from campfire in the way, then continue to flee from target. the two actions combine to create "flee with campfire obstacle avoidance".

the combo of priorities and separate variables for actions works like an action stack, allowing a lower priority action to be paused while a higher priority one is executed, and then automatically resume.


Is the problem that the decision system (if..then..else) is becoming unwieldy because of too many cases?

no - just the large number of variables. and its not really an issue. just in-elegant. but that may be because i have yet to consolidate the mutually exclusive cases.


Sigh.

<g>.

i'm 24 minutes into the video so far.

would you say this is an accurate statement:

"in an expert system / decision tree / behavior tree (whatever you want to call it), actions are prioritized, and considered in priority order, with the first one that looks good being selected. whereas in a "planner", actions are not prioritized - instead, all actions are considered and scored, with the high score being selected."

i guess the way i always thought about it was that if certain actions needed to be considered first, and selecting them precluded the need to consider other actions, then considering all actions was a waste of time.

in my case, i've never had a very large set of mutually exclusive actions that an entity could choose from. for something like SIMTrek, i actually built a separate little decision maker for every system on the ship. i've found that this divide and conquer strategy of using a hierarchy of decision trees works well.

the other thing that i've come away with so far from the video is that my problem apparently is not in the AI decision making, but rather in the in-elegnce of game's implementation of the action chosen by the AI.

i assume that with proper bookends, weights, curves, and curve parameters, a planner would yield the same results as a decision tree, correct?

in which case a planner might be overkill for my needs.

i assume a lot of the advantage is in the flexibility and ease of modification.

i'm going to finish watching both videos, then think about it some. right now i don't see planner vs decision tree changing the number of considerations required for input, nor having anything to do with the in-elegance of the game's implementation of actions chosen as output. its not the black box AI that's the problem, its making the correct decisions and runs plenty fast - except for pairwise range calculations of all entities every update <g>. and its not the number of variables you have to plug into the black box AI as input. its how the game implements the chosen action that the black box AI spits out.

BTW i love the visual curve tool. i just got done deriving the formulas for hp, xp, meat, hides, bone, and tendon based on body mass for the game. i had to do all the curve visualization in my head.

the planner strikes me as almost a neural net way of getting an answer. kind of like a one layer NN.

in practice,how difficult is it selecting curves, curve parameters, bookends, and weights for a given consideration? i assume that bookends would be pretty obvious, and after a while, you'd figure out the curve type to use for a given type behavior. but weights, and especially parameters, might require some dialing-in?

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

i found it interesting that at time index 28:19 they mention that as part of the optimization, they limited the AI to consider no more than 12 agents within 4000 ft range (visual range). of course that's in a MMO - you got a LOT of active agents in a MMO <g>. In caveman, i'm currently running at 550 agents max within visual range. in actual gameplay i've gotten as many as 200-250 active at once. single player only, of course.

so this brings up the obvious question of planner vs decision tree performance. have you ever done an analysis?

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php


you can be fleeing, hit total fatigue and have to collapse on the ground in exhaustion, once you can stumble on, you continue fleeing,

Yes, but you're still only doing one at a time. While you're passed out with exhaustion you're not fleeing.

The minute you're recovered you re evaluate the situation and this could put you back into fleeing state, or another caveman may have killed the sabertooth tiger chasing you, and you can read evaluate to a different state instead or continue to fully heal, rather than just recovering enough to get away from danger...

The point I am trying to make is continual re evaluation of the situation, based on current input from outside stimulus.


would you say this is an accurate statement:
"in an expert system / decision tree / behavior tree (whatever you want to call it), actions are prioritized, and considered in priority order, with the first one that looks good being selected. whereas in a "planner", actions are not prioritized - instead, all actions are considered and scored, with the high score being selected."

Your statement is mostly correct. However, the architecture in the video (mine), is not a planner. It does not assemble a plan sequence of multiple steps. It does score all the available actions and pick the highest. It's just not a planner. (The go-to term is "utility-based system".)


i guess the way i always thought about it was that if certain actions needed to be considered first, and selecting them precluded the need to consider other actions, then considering all actions was a waste of time.

As you should have seen from the video, we have a way of realizing when it is no longer worth it to check certain items since they can no longer win. We then skip over them.


the other thing that i've come away with so far from the video is that my problem apparently is not in the AI decision making, but rather in the in-elegnce of game's implementation of the action chosen by the AI.

I dunno... I wasn't really thrilled with your explanation of your decision-making either. *shrug*


i assume that with proper bookends, weights, curves, and curve parameters, a planner would yield the same results as a decision tree, correct?

Yes and no. While it could yield the same results it wouldn't always do so due to the fact that the inputs are far more fluid.


in which case a planner might be overkill for my needs.

you-keep-using-that-word.gif


i assume a lot of the advantage is in the flexibility and ease of modification.

Yes. The fact that you can treat each action separately, with its own relevant inputs, gives you a load of flexibility that you were never going to accomplish with your mess of rules.


the planner strikes me as almost a neural net way of getting an answer. kind of like a one layer NN.

Dude... WTF? If you mean "it uses combinations of numbers to arrive at something", yeah I suppose.


in practice,how difficult is it selecting curves, curve parameters, bookends, and weights for a given consideration? i assume that bookends would be pretty obvious, and after a while, you'd figure out the curve type to use for a given type behavior. but weights, and especially parameters, might require some dialing-in?

I'm kind of a bad person to ask since I'm the one who developed a system entirely around how I view the world. However, we had the designers at ArenaNet not only assembling the pre-done modules but designing their own ad hoc ones as necessary. And yes, all AI requires "some dialing in", doesn't it? You get used to it, though.


i've gotten as many as 200-250 active at once. single player only, of course.

In the video that you don't see much of on the there (they cut to me and Mike), we had 300+ enemies all in combat together. I don't know what kind of processor was doing all of that, but I don't think you should have a problem with it.

As far as utility (not planner) vs. behavior tree, the utility system might be a bit more expensive? Depends on what you have in each one. However, the non-rigid behaviors it affords you is well worth it.

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

A planner is designed to come up with sequences of actions to achieve some goal. To get the same results from a utility system is almost impossible, it would require incredibly deep nesting and scoring and caching all combinations of actions. The utility system is limited in how many "steps" or actions it can look ahead, and they have to be crafted by a designer, while the planner has no such limit.


The point I am trying to make is continual re evaluation of the situation, based on current input from outside stimulus.

it does that already.

fleeing and fatigue are a bad example, as flee re-evaluates frequently, perhaps every update - i'd have to look it up.

actually, i think there are very few combos that don't re-evaluate the resumed action once the interrupting action completes. wander and migrate come to mind, and collision avoidance. all three move to a specific location or in a specific direction for a specific number of updates. and if interrupted, they simply resume without choosing a new direction or location. but that would be about it.

as i said, i have yet to evaluate which cases are mutually exclusive and can therefore share variables. OTOH, i already do a lot of that for variables for animals, reuse variables for other things in mutually exclusive cases. it does save on a ton of unique variables, at the expense of a given variable meaning one thing if the npc is a thief, anther if they're not, and a third thing if they're dead. for ease of maintainability i suspect not reusing variables is really the way to go. one of the things that makes me not like to declare new variables is the fact that it means i have to export and import all the long term playtest save games when the variable gets added to the save game file format. i've got that down to just a load, a save, and a recompile (with a 2 minute link time) but its still a disincentive vs a game that doesn't have to maintain backwards compatibility of save game files during development.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php


As you should have seen from the video, we have a way of realizing when it is no longer worth it to check certain items since they can no longer win. We then skip over them.

yes, but you still have to touch each one to see if its below min. a decision tree would never even touch a losing consideration. it would act before it even got to it. but i suspect the performance hit is not significant enough to worry about.


Yes and no. While it could yield the same results it wouldn't always do so due to the fact that the inputs are far more fluid.

so in some of these more fluid edge cases where curves and weights and such combine to yield different results, those results might be considered sub-par from an expert system point of view? IE it won't always make the best move every time?


Dude... WTF? If you mean "it uses combinations of numbers to arrive at something", yeah I suppose.

B.G. inputs, weights, 0 to 1 values, outputs - all very NN-ish type stuff - thats all i'm sayin'. fortunately, unlike a NN, there's none of that "inputs go here, outputs go there, and in the middle - a miracle occurs". kinda stuff.


As far as utility (not planner) vs. behavior tree, the utility system might be a bit more expensive? Depends on what you have in each one. However, the non-rigid behaviors it affords you is well worth it.

so with a low number of considerations per entity, it might work ok for a large number of entities. something to check into.

the non-rigid behavior is a potential concern though. at least to start, my goal is to have the AI always do the best thing possible, or at worst choose from equally valid options at random. right now the only place to do that is deciding which way to turn when recovering from a collision, or a random flee or wander direction. for pretty much everything else, there's always only one best possible move. at least until you get into combat strategies like targeting greatest threat vs weakest threat vs closest threat first. odds are there's a dominant strategy for that too.

i assume that with proper weights and such a utility based system can be calibrated to always yield the best move, perhaps at the cost of some fluidity of behavior.

one thing i found especially interesting was the use of influence maps as an alternative to pairwise comparison of entities. similar to using a collision map instead of looping though a sparse matrix of obstacles checking for collisions. i wonder if i might use that to speed up target selection, which currently does pairwise range checks in a round robin fashion. the round robin reduces the responsiveness time of the AI to new targets entering their personal space at high speed. right now its just ok with a response time of 1-2 seconds, but i'd like to get it back down to 1/15th of a second response time.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

The purpose of a planner is figuring out what to do when immediately executable actions don't achieve goals directly and therefore choosing an appropriate one isn't obvious.

For example, running directly away from the campfire ("flee from fire" goal) is an approximation of the best way to escape: it's optimal in completely open terrain, but it could lead the animal into a cul-de-sac with impassable obstacles; a planner that figures out an appropriate path to a good place far from the campfire and can issue a wider choice of orders (including going near the fire to reach an opening before going away) is a more robust controller.

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement