Heuristics

Published November 16, 2013
Advertisement
T9BXgG0.jpg

As a first whack at the combat pathfinding heuristics, I built a heuristic function that assigns a cost of Distance for an open tile, Distance-1 for a resource node, Distance+10 for a tile with a different-faction destructible, and Distance+20 for a tile with a same-faction destructible. And it works pretty dang well. When presented with a choice of turnings, with either turning being the same cost distance-wise, if one turning has a resource node and the other does not then the resource node turning will be picked. Enemies don't exactly go out of their way to loot things, but they will loot if the lootable is convenient or in the way. They will favor looting a lootable over destroying a barricade, given a choice, but if the only choice is to destroy a barricade or a Tiny Bombard, then they'll do it. If the last resort is to find a path that is blocked by a same-faction ally, then they will follow that path for as far as they can. This ensures that even if GC is completely encircled by the foe, other foes will continue to path toward the fight and pile up around GC in a wonderfully overwhelming manner.

And it all works. However, it is a tad bit slow since I implemented the new AI pathfind in Lua. I might need to move it into C++ and do some optimizations to make it faster, since as of now there is a tiny but noticeable hitch right as an enemy unit starts its turn, while it paths and weighs its options. I have thought, too, about making the pathfinder incremental; letting it run for a few fractions of a second at a time then exiting. This would be simple enough to do if I restructured the pathfind slightly as a Lua coroutine, so that might be the first option I try. That way, the pathfinder would be running behind-the-scenes so to speak. It would be granted a few cycles every Update, and that would prevent any visible framerate hangs or hitches.

This current heuristic would be trivial for the player to game, given the right mix of skills and enemies. But with the test sets, it works wonderfully. And in the process, I even fixed a previously-unnoticed hang-bug I found in some movement queueing code, a bug that wasn't being triggered by the previous path assignment functionality.
Previous Entry Pathfinding
5 likes 3 comments

Comments

JTippetts

One fun side-effect of the way the lootables are weighted is that if you have a small, compact base and the Things breach your barricades, they will absolutely loot the [i]shit[/i] out of your workbenches when they raid unless you plan in advance.

November 16, 2013 02:58 PM
JTippetts
prsnSe6.jpg

Near-perfect spawn location to build a base, and I still got owned. I think I liked these things better when all they did was wander around randomly.
November 17, 2013 05:14 AM
molehill mountaineer

It looks real neat, I'd love to see a gameplay video of the little bastards in action!

November 17, 2013 10:51 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement