Pathfinding, Doors, Queues, and Items

Hey Folks! Bit of a slog today, as I continue working through some annoying bugs in the pathfinding, queue, and other systems.

I was able to figure out why AI prematurely triggered interactions while walking towards them. Basically, the code to calculate range to target in tiles was incorrectly converting units, causing most distances to be 0. In other words, the AI almost always thought it was close enough. Once I fixed that calc error, the AI would correctly wait until it arrived at a destination before triggering its interaction or UI.

And for a while, I thought that was it. I moved on to a minor issue with pathfinding that caused AI to always spiral down and out before setting off to a target, which turned out to be a typo in the code. And while in there, I noticed a place where the pathfinder should bail if the current interaction is null.

I also finally figured out why my animations were sometimes not playing. Seemingly at random, the AI would get stuck playing walk or use animations when doing anything other than standing idle. And as it turns out, this was a bug in the animation state machine. It was waiting for an "idle" signal to exit "use" and "walk" states, which doesn't happen if the AI goes straight from "use" to "walk" or vice versa. Changing the conditional tests there was pretty easy, and now AI looked much better, doing appropriate animations for each action.

Finally, I also noticed a bug in hull patching that occurred when the AI automatically retrieved a hull patch kit before moving on to repair a hole. The range info on that interaction was wrong, so AI was repairing from across the ship. Again, small typo was easy enough to fix. Just hard to find.

I thought I was in good shape after that, but I started noticing more bugs as I tested these. As it turned out, my AI was unable to continue certain actions after passing through a door.

The pathfinder code inserts an "open door" action into the queue when the AI's next step would intersect a door, and that seems to work as expected. But as soon as that is done, the AI resumes walking as if the target is right at the doorway. Things are a bit better if the AI was on its way to interact with an item. It just pauses, recalculates pathfinding, and continues on. The pause isn't great, but it works.

But if the AI was just walking to a tile, such as when the player tells it to go there, the AI gives up in the doorway after opening it. The walk command is still in the queue, but it's like the command's target tile moved to the door. I can see in the code that the target is right, so this is starting to look like another pathfinding bug. I.e. the pathfinder had its goal changed somewhere in there, and never got reset to the ultimate goal.

I thought I was being clever by recalculating pathfinding any time the command queue's head changed (i.e. when a new action was added, or any action was removed), but no change. I'll have to dig into this a bit more to see why.

Overall, I guess today wasn't a bad day. A lot of tricky, annoying bugs got solved. But it sure would be nice to be back into working on fun-factor instead of bugs!


florinteal's picture

I'm interested in what kind of fantasy tech is going to be involved in this game given the fact that you seem to be using a real world rocket fuel setup. Sounds like you're going for a sort of low-fantasy theme as opposed to lasers, teleporters, forcefields and other similar Trek-type stuff?

dcfedor's picture

Exactly. The tech will be more like the Expanse, Alien(s), and Firefly instead of magitech like Star Trek or Guardians of the Galaxy. Plausible science, with some bending of rules where needed.

That said, it's still the NEO Scavenger universe. So the unexplained will still be featured here and there. Instead of Hidden Lake, there might be a haunted derelict. Or instead of dogmen, there might be bioweapons experiments gone awry.

Also, you list some interesting examples which kind of straddle the lines of fantasy/science. E.g.:

  • Lasers - While there won't be "pew-pew" lasers axially mounted for dogfighting, the idea of a high-powered laser mounted on a turret for point defense against incoming ballistics/drones/micrometeoroids is actually present-day tech, and might be common.
  • Teleportation - No stepping into a teleporter to "beam me up," but ZP Telecom operates low-bandwidth, instantaneous communications using their secret tech (quantum entanglement pairs).
  • Forcefields - Nothing that would stop a bullet, laser, or micrometeoroid, but some ships might feature artificial magnetic fields to shield against radiation. Particularly in the high-energy region around Jupiter.

Basically, if it works today, or seems like it might be "just around the corner" tech, it'll be mature tech in this game.

Dan Fedor - Founder, Blue Bottle Games

florinteal's picture

I can tell you get a kick out of researching background for your settings. I can relate to this. :)