A*-like Pathfinding with Momentum
You have your regular A* graph which is used when starting from a full stop. Then you generate 8 x 3 subgraphs for the 8 directions and 3 movement speeds. The subgraphs are weighted essentially the same, but smeared in the direction of travel by the speed. So obstacles get bigger in the direction of travel (don't want to run into them at full speed) and small gaps in terrain become traversable by jumping. Costs of turning are increased according to speed. The subgraphs are joined to neighbouring speed subgraphs but only in the current direction of travel, or perhaps diagonals at lower speeds. Therefore the same physical terrain can be explored multiple times by A* for different speeds, if the higher speeds can be attained in the space given. It would even allow backing away from a gap to get up speed to jump across it.
The downside of course is a huge search space, and only rough equivalence with the actual physics model. I haven't had the chance to think it through, but I expect that some of the common ways of speeding it up such as Hierarchical A* wouldn't work without modification, as many make topographical assumptions. I suppose you could set a benchmark by using the lowest speed subgraph, and use this as an upper limit on the full graph A*. Also it's not clear how acceleration comes into it, e.g. how big a run-up to get from speed 1 to speed 2.
Thoughts? Comments?
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!"
It would seem that if your network is so granular as to fall well within the momentum-based turning radius of your agents, that you are going to have a shitload of nodes.
It would seem that you're correct. ;) I know this, but not sure what else one can do. I saw a few other questions on this sort of thing, but the answer was invariably "use steering behaviours" or hand place nodes where special movement activities can happen.
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!"
An alternative I suppose would be a static analysis of the map which determines which gaps have a big enough run-up nearby to potentially jump over, then give those cells a highish (but not infinite) cost. If the steering behaviour later determines the jump is impossible, then the A* map would need to be revised to make the gap impassible, e.g. the agent would go for the gap, chicken out, then try another way.
In your case, you would create edges over gaps statically, and assign them some kind of flag which indicates they are jumpable. The context then marks the point in the generated path where the jump would occur along with how "hard" it is to make the jump itself. In your steering layer, you approach the jump and look up the difficulty of the jump. If the difficulty is too high, you stop, and recompute the path from that point, this time informing the context that you can't make the leap. In the majority of cases, your agents can make the jump fine; if they happen to be slowed down for some reason on the way, you simply re-path and figure it out as though the jump isn't available.
There is certainly a bit of an art form to getting pathing and steering to work nicely together, but it's more about handing off decisions back and forth at appropriate times than about trying to cram all the logic into one or the other of the layers. They need to stay balanced between the two approaches to movement; think of it as a yin/yang sort of situation rather than "oh crap I have two competing things and one of them should go away." There's a harmony there that works best at a certain mixture (which varies based on the game you're making of course) and tending too heavily towards steering or pathing just introduces lots of complication.
Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]
I think that these kinds of questions of responsibility are often tricky. Where do you hand off between animation, steering, pathfinding, planning and group planning? Every answer that I see seems to cut it slightly differently. ;)
Also, remember to not just think of momentum as an aftereffect that you can't control. Think in terms of how your agents might be aware of their own momentum and plan on it for turns. So, for example, if they have plotted a path that goes through a narrow gap, they will adjust accordingly before they get to the gap. The only time momentum really screws with you is when you have to repath suddenly.
Another thing to remember is to use changes in speed. In the example of planning ahead, a common technique that we would use is to slow down so as to make our momentum more controllable. Many games don't adequately use speed control to "sell" their movement.
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!"