dwarfcorp icon indicating copy to clipboard operation
dwarfcorp copied to clipboard

AI: "Air humping" - Dwarves getting stuck in pathing loops

Open com1clyf3 opened this issue 6 years ago • 10 comments

https://steamcommunity.com/app/252390/discussions/1/1692669912390094558/

Secretaryland_480_131813429616057161.zip Secretaryland.zip

See Steam thread above. Looks like they're experiencing more and more pathing loops from crafters, the farther they play into the game. I've requested they send us a save. Not exactly sure what they're experiencing, but I've observed a pattern of bug I've been trying to suss out that sounds familiar. Not 100% on the repro, but this is usually how it occurs:

  1. (I usually use cooking, but I'm guessing any repeatable craft works) Set a repeatable task, like 10x cooking meals.
  2. After the Crafter is done, set another 10x crafting meals.
  3. Observe the Crafter eventually become stuck on a few voxels jumping back and forth (the "humping" I think the player is referencing)
  4. Eventually they'll become unstuck form this behavior, but then eventually caught in a new loop, pathing back and forth between the crafting station and another location, usually a stockpile. The task will still be to cook, but the Crafter seems unable to collect the required resources for some reason. Canceling the task resolves the bug.

1299186a

com1clyf3 avatar Sep 13 '18 20:09 com1clyf3

I believe I have fixed the root cause of this issue by accident while developing palisades. Will test this save to see if I can reproduce it.

mklingen avatar Sep 16 '18 18:09 mklingen

okay, I believe I have fixed this, and that save does not currently have the problem.

Forensics:

  1. When crafting multiple items, and "Any" is selected as an ingredient, the dwarf assigns random goods from your stockpile to be the source of the item.
  2. If the crafting gets interrupted, it gets put back on the task queue with those selected ingredients.
  3. If those ingredients are no longer present for whatever reason (maybe another dwarf ate them), the dwarf believes the resources are available, but they are in fact unavailable.
  4. When the dwarf arrives at the crafting station, it believes that it has the resources already, but when it looks in its backpack, it finds the resources to be missing.

I fixed this by making the crafting task clean up after itself on failure, and made the dwarf check the contents of its backpack to be extra sure that it has the resources before attempting to craft.

mklingen avatar Sep 16 '18 18:09 mklingen

Still seeing this behavior:

Observe the Crafter eventually become stuck on a few voxels jumping back and forth (the "humping" I think the player is referencing)

in 233bc5a8

It's not exclusive to crafters.

com1clyf3 avatar Sep 24 '18 20:09 com1clyf3

That example doesn't seem to have the problem you're describing...

mklingen avatar Sep 29 '18 18:09 mklingen

although it does have a ton of other problems mainly with pathfinding, which is pretty baffling

mklingen avatar Sep 29 '18 18:09 mklingen

Some possible issues I just fixed from this save:

  • If plans were taking a very long time, it was possible dwarfs could abandon them before the planning was finished. The next time the dwarf would try to get a path from the planner, it would be the old path. Fixed this by assigning an ID to each path plan.

  • While "taking a walk" dwarfs were sometimes jumping up and down on the same spot over and over. Prevented this.

  • Radius of path plans was just not set correctly.

  • The greedy fallback is awful and almost never works. I removed this completely and now dwarves have reverted back to their old behavior of standing still while waiting for a plan.

mklingen avatar Sep 29 '18 21:09 mklingen

Also fixed this issue

  • Upon loading from a file, the dwarf's planners weren't getting set up correctly. As a result, dwarfs were getting their paths mixed up with other dwarfs. This generally wrecked mayhem.

mklingen avatar Sep 29 '18 23:09 mklingen

While "taking a walk" dwarfs were sometimes jumping up and down on the same spot over and over. Prevented this.

Thems the humps, so it's fixed.

com1clyf3 avatar Sep 30 '18 00:09 com1clyf3

This is still occurring on b089ea7a

Bead Realm_53_131841106693600935.zip Bead Realm.zip

com1clyf3 avatar Oct 15 '18 21:10 com1clyf3