Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Pathing and Connectivity  (Read 2186 times)

Infiltrator

  • Bay Watcher
    • View Profile
Pathing and Connectivity
« on: July 19, 2009, 12:43:30 pm »

The idea of this post is to gather as much data on DF pathfinding as possible. I hope to be able to have everything related to it in here, eventually. I would appreciate help in this. Feel free to provide links and/or data.

I will also be posting previous suggestions here, as well as summaries. Feel free to correct me if you believe I have misunderstood your suggestion.


Okay, well, having played DF a bit now (around a month or so), and lurking these forums, I see that pathfinding seems to be an issue.

Before making any kind of suggestions, though, I'd like to compile as much information on the matter as possible. (Other people also expressed the desire for such a compilation, and a search for "pathing" did not turn up any such repository.)

I'll try to make clean lists, with references where necessary.

Hopefully, I'll be able to compile all the information on pathing into here.



Reported problems with current system
  • Z-level pathing difficulties. A dwarf would rather walk halfway around the map to get to a stone directly below him than one right next to him because it's "zero" steps away
    Spoiler (click to show/hide)
  • Constant pathfinding eats CPU (doesn't really need a reference)
  • Animals pathfind too much, combined with above
    Spoiler (click to show/hide)
  • Dwarves cannot dodge obstacles
    Spoiler (click to show/hide)
  • Up, down, can't go up again? UNCONFIRMED?
    Spoiler (click to show/hide)
  • Mining (of all forms, I believe) dwarves would rather take a long path to approach a tile from another direction than the one they're currently facing it at, because they prefer north
    Spoiler (click to show/hide)
  • Toady's comments from an interview found at http://www.gamasutra.com/view/feature/3549/interview_the_making_of_dwarf_.php?page=8
    Spoiler (click to show/hide)


Resources



Previous suggestions
  • Connectivity map 06/04/09 by Fieari
    Summary
    Spoiler (click to show/hide)
    Full post
    Spoiler (click to show/hide)
  • A new approach to path finding (nice pun :P) on 09/11/08 by catpaw
    Summary
    Spoiler (click to show/hide)
    Full post
    Spoiler (click to show/hide)
  • Route caching on 02/12/08 by Ogantai
    Summary
    Spoiler (click to show/hide)
    Full post
    Spoiler (click to show/hide)



Current development
  • I'm going to need some help here. I'm not exactly sure what's being done right now regarding pathfinding.
    Preferably from ThreeToe or, if he has time, Toady.



*MY* Personal Issues (excluding those already diagnosed by psychiatrists)
Spoiler (click to show/hide)
« Last Edit: July 20, 2009, 05:30:57 pm by Infiltrator »
Logged
GENERATION 25:
The second time you see this, copy it into your signature on any forum and add 2 to the generation. (Slight mutations allowed)
Sociopathic experiment.

Fieari

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #1 on: July 19, 2009, 01:29:47 pm »

The problems are well known (other than the up-down-up-down thing... I don't even think that's true-- A* doesn't have limitations that would cause that, and neither does the connectivity map).  Do you have solutions to suggest?

The near-omniscience issue is partially solved next version anyway, with some temporary FOW implemented (Command & Conquer style, not starcraft style)
Logged

Kilo24

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #2 on: July 19, 2009, 01:33:56 pm »

With telepathy, I can't imagine how it would be done without individual line-of-sight calculations for each dwarf with regards to pathfinding.  Though it already does the job cancellation when they encounter a hostile, the pathfinding (I think) is a separate beast entirely and would have to repeat those calculations.  Even if that's not the case, we'd be in a worse situation as we'd need separate mental maps for each creature and have to deal with transferring them to each-other somehow unless every dwarf needs to check that the river is now indeed empty.

Doing a separate mental map for each side would be better, but it would be painful to get the invading goblins to assault the fortress effectively.  Of course, if they traded with or tortured trading partners of you, they might be able to discover the traders' map of your place.  And it would give them a plausible excuse for knowing that your fortress exists and how to get to it.  And it would allow for you having an actually secret door, as well (without using levers or locking it yourself).  Another learning aid could be thieves just shadowing your dwarves to map out the place.
Logged

Grendus

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #3 on: July 19, 2009, 02:26:50 pm »

Removing omniscience from dwarves would spike the lag. I'd leave it for right now. I lag already.
Logged
A quick guide to surviving your first few days in CataclysmDDA:
http://www.bay12forums.com/smf/index.php?topic=121194.msg4796325;topicseen#msg4796325

Granite26

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #4 on: July 19, 2009, 05:39:03 pm »

Thanks for the hard work, Infiltrator.  It will be useful to point people to this thread in the future.

Consider linking (at the tail end) some of the CS level user discussions.

Impaler[WrG]

  • Bay Watcher
  • Khazad Project Leader
    • View Profile
Re: Pathing and Connectivity
« Reply #5 on: July 19, 2009, 06:27:36 pm »

I think omniscience can be split into two broad categories, Omniscience of 'People' and Omniscience of 'Things'.  The former is the ability to home-in on someone (like the Mayor) and is rarely used because their are so few pre-determined interactions.  People have made good recommendations on the use of offices (one party goes to the office and waits for the other to arrive) to eliminate this weirdness. 

The later type of Omniscience is further sub-divided into 'Path' Omniscience and 'Item' Omniscience both rather self explanatory.  A system of pre-caching paths and giving individual dwarves some references to those paths might be able to create a reasonable approximation of personal memory, dwarves would not immediately take the newest shortest path and would try (and fail) to use an old path that's been blocked just as they do now if the map changes after they have started traveling.  Omniscience of Items is perhapse the trickiest thing to resolve because we really at some level must retain it if we expect to keep the fortress clean.  What we really want is a strong preference for items that are logically 'known' to a dwarf.  The most logically known items should be in stockpiles so dwarves should go to stockpiles preferentially when they want something.  On top of that dwarves could have some 'mental notes' on items outside of stockpiles.  Say for example you've mined out a large room any dwarf passing through that room notices the stone and gets a "un-stockpiled stone at coordinates x,y,z", these notes don't have to be any more detailed then that and would of course expire after a while (or a failed attempt to collect the thing in question).  Dwarves would use these mental notes either when stockpiles are exhausted or when they do hauling tasks (trying to fill stockpiles).  Dwarves could even exchange these notes when they are socializing or working so information can spread in a realistic manor.
« Last Edit: July 19, 2009, 06:29:35 pm by Impaler[WrG] »
Logged
Khazad the Isometric Fortress Engine
Extract forts from DF, load and save them to file and view them in full 3D

Khazad Home Thread
Khazad v0.0.5 Download

Infiltrator

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #6 on: July 20, 2009, 07:03:18 am »

The problems are well known (other than the up-down-up-down thing... I don't even think that's true-- A* doesn't have limitations that would cause that, and neither does the connectivity map).  Do you have solutions to suggest?
I know that the problems are well known by SOME people. However, not everybody knows the whole story, certainly not me. And yes, I do have a suggestion, but I would like to collect as much data as possible to avoid making a suggestion that has already been rejected, that would not work, or would cause problems.

The near-omniscience issue is partially solved next version anyway, with some temporary FOW implemented (Command & Conquer style, not starcraft style)
Like I said, I'd like to collect as much data as possible.

With telepathy, I can't imagine how it would be done without individual line-of-sight calculations for each dwarf with regards to pathfinding.  Though it already does the job cancellation when they encounter a hostile, the pathfinding (I think) is a separate beast entirely and would have to repeat those calculations.  Even if that's not the case, we'd be in a worse situation as we'd need separate mental maps for each creature and have to deal with transferring them to each-other somehow unless every dwarf needs to check that the river is now indeed empty.

Doing a separate mental map for each side would be better, but it would be painful to get the invading goblins to assault the fortress effectively.  Of course, if they traded with or tortured trading partners of you, they might be able to discover the traders' map of your place.  And it would give them a plausible excuse for knowing that your fortress exists and how to get to it.  And it would allow for you having an actually secret door, as well (without using levers or locking it yourself).  Another learning aid could be thieves just shadowing your dwarves to map out the place.
Removing omniscience from dwarves would spike the lag. I'd leave it for right now. I lag already.
I think omniscience can be split into two broad categories, Omniscience of 'People' and Omniscience of 'Things'.  The former is the ability to home-in on someone (like the Mayor) and is rarely used because their are so few pre-determined interactions.  People have made good recommendations on the use of offices (one party goes to the office and waits for the other to arrive) to eliminate this weirdness. 

The later type of Omniscience is further sub-divided into 'Path' Omniscience and 'Item' Omniscience both rather self explanatory.  A system of pre-caching paths and giving individual dwarves some references to those paths might be able to create a reasonable approximation of personal memory, dwarves would not immediately take the newest shortest path and would try (and fail) to use an old path that's been blocked just as they do now if the map changes after they have started traveling.  Omniscience of Items is perhapse the trickiest thing to resolve because we really at some level must retain it if we expect to keep the fortress clean.  What we really want is a strong preference for items that are logically 'known' to a dwarf.  The most logically known items should be in stockpiles so dwarves should go to stockpiles preferentially when they want something.  On top of that dwarves could have some 'mental notes' on items outside of stockpiles.  Say for example you've mined out a large room any dwarf passing through that room notices the stone and gets a "un-stockpiled stone at coordinates x,y,z", these notes don't have to be any more detailed then that and would of course expire after a while (or a failed attempt to collect the thing in question).  Dwarves would use these mental notes either when stockpiles are exhausted or when they do hauling tasks (trying to fill stockpiles).  Dwarves could even exchange these notes when they are socializing or working so information can spread in a realistic manor.
I do have some ideas for this, that may actually reduce lag, but like I said, I'd like to collect as much data as possible lest I propose a solution that would not work.

Thanks for the hard work, Infiltrator.  It will be useful to point people to this thread in the future.

Consider linking (at the tail end) some of the CS level user discussions.
It would help if other people also helped me to compile this. Feel free to provide links/data.


PS, wow, how did the forum find out that I'm an escaped lunatic? That is pretty impressive.
« Last Edit: July 20, 2009, 07:40:26 am by Infiltrator »
Logged
GENERATION 25:
The second time you see this, copy it into your signature on any forum and add 2 to the generation. (Slight mutations allowed)
Sociopathic experiment.

Starver

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #7 on: July 20, 2009, 08:37:18 am »


Quote
TA: Yeah, it's nice that they can solve an arbitrary labyrinth of your own design, and they'll pick the best possible path, generally. There are some exceptions, like mining where they can mine from multiple sides, and don't try them all.

I still think this is solvable by running the A* with the designated to-be-dug tile made a "pathable-to" tile (within the scope of this particular path-searching attempt only, obviously), and the destination, rather than (as I understand it) accepting its status as a barrier when looking to see which cell one (choosing the first of N,S,W,E,NW,NE,SW,SE, in that order?) can ultimately accesible to dig from and then running A* with that as the destination, even if it means circumnavigating the mountain to approach from the north rather than staying in the same place and digging out from the SE.


As an addition to the discussion, the assignment of a more logical sequence (or resequencing/reassignment, on-the-fly) of digging/channelling/ramping jobs is a different issue, so I won't mention it, but it is related to what I think is the clincher in the pure domain of pathing: i.e. not taking account of currently active (e.g. digger being on the way) channelling, other barrier-building activities or floodgate/bridge operation along the path of a routing actor, or responding in a reasonable manner when said change occurs.

The impression of omniscience falls down a bit when a pathing dwarf (or creature of some other kind[1]) who has happily worked out a route from where they are to a previously unknown area located in a part of the map they have never been before, gets almost all the way there and then finds the way blocked by a change in map dynamics that occured almost immediately after it set off, and then heads back almost all the way to the original starting location to take the alternate route that left unblocked (at the risk of having to repeat if that is blocked off, and not immediately retrying the original route if re-opened just as they turn back).  I have no problems with the omniscience (it is less processor intensive than working out the background data to an "Artificial Ignorance" pathing algorithm that requires per-actor knowledge to be gained before each can successfully traverse the most efficient path) but at the risk of needing the reloading of connectivity zones perhaps initiate a "recalculate route" event whenever gaps/barriers are opened/closed.

Perhaps stagger the recalculations task for each actor, after a short semi-random delay, after each path-change event that restricts travel.  With similar but slightly less recalculation events for potential route openings (shorter routes being missed having less repurcussions than original routes needing to be diverted).  This way it does not all occur on the same tick and (like the generation of an incoming caravan or newborn child entity causes a noticable pause in the game, for me, while it calculates all the new data) but buries itself in the background a little and facilitates a more natural reaction than everyone suddenly reversing direction like some kind of dwarven Village Of The Damned reacting to a world change...

(On the other hand, these 'flaws' in the system do allow various Dwarf Computing dynamic setups to work. :))


[1] Actually, while my dwarfs tend to be stupid about this, I've had invaders start to enter a relatively short tunnel to the Depot, and then activated the drawbrige (tens of tiles away, definitely not yet reached by the hostile force) designed to force them to reassess and take another branch of tunnel once they hit this barrier.  But instead of advancing and then reassessing, they've immediately turned round, headed back outside and wandered around to the alternate external entrance that is (I freely admit) actually the shortest path given their insufficiently progressed, but would not be if they hadn't responded until meeting the new obstruction.  I can only assuming that as an aimless rabble with a generic "search out targets" algorithm, that they reassess their path far more often than a dwarf who tends to attempt a single targetted task until it comes up against an obstacle or realises that the item has dissappeared (e.g. been channeled under).  Not noting any appreciable hit in speed, I'm wondering how much extra power they are taking on, or whether it's mitigated by being a general search for "closest thing of interest" rather than "shortest path to specific target", and thus hits 'maximum depth' far sooner.  Noting that I might be misconceiving some aspect of the scenario.
Logged

Infiltrator

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #8 on: July 20, 2009, 09:01:39 am »

The impression of omniscience falls down a bit when a pathing dwarf (or creature of some other kind[1]) who has happily worked out a route from where they are to a previously unknown area located in a part of the map they have never been before, gets almost all the way there and then finds the way blocked by a change in map dynamics that occured almost immediately after it set off, and then heads back almost all the way to the original starting location to take the alternate route that left unblocked (at the risk of having to repeat if that is blocked off, and not immediately retrying the original route if re-opened just as they turn back).  I have no problems with the omniscience (it is less processor intensive than working out the background data to an "Artificial Ignorance" pathing algorithm that requires per-actor knowledge to be gained before each can successfully traverse the most efficient path) but at the risk of needing the reloading of connectivity zones perhaps initiate a "recalculate route" event whenever gaps/barriers are opened/closed.

Perhaps stagger the recalculations task for each actor, after a short semi-random delay, after each path-change event that restricts travel.  With similar but slightly less recalculation events for potential route openings (shorter routes being missed having less repurcussions than original routes needing to be diverted).  This way it does not all occur on the same tick and (like the generation of an incoming caravan or newborn child entity causes a noticable pause in the game, for me, while it calculates all the new data) but buries itself in the background a little and facilitates a more natural reaction than everyone suddenly reversing direction like some kind of dwarven Village Of The Damned reacting to a world change...

(On the other hand, these 'flaws' in the system do allow various Dwarf Computing dynamic setups to work. :))
I specifically put that unless a "my personal issues" heading for a reason. :P
However, I do have some ideas about it, that, at least to me, in my head, seem reasonable.
Logged
GENERATION 25:
The second time you see this, copy it into your signature on any forum and add 2 to the generation. (Slight mutations allowed)
Sociopathic experiment.

Starver

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #9 on: July 20, 2009, 10:15:38 am »

I specifically put that unless a "my personal issues" heading for a reason. :P
Oops, I'd missed that particular spoiler-expansion section, after going down and reading (or at least skimming!) the whole lot.

Plus I appear to be typing far too much, today, when just meaning to type basic points/responses, but that's not an issue restricted to this thread/forum.  :D
Logged

Fieari

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #10 on: July 20, 2009, 02:05:00 pm »

I take back my earlier complaints, I didn't realize you were organizing a central megathread for all pathfinding issues.  I approve.  Good organization too!
Logged

Granite26

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #11 on: July 20, 2009, 02:07:56 pm »

I take back my earlier complaints, I didn't realize you were organizing a central megathread for all pathfinding issues.  I approve.  Good organization too!

You're fortunate I'm over my quota for snide for the week :-p

Rowanas

  • Bay Watcher
  • I must be going senile.
    • View Profile
Re: Pathing and Connectivity
« Reply #12 on: July 20, 2009, 04:53:52 pm »

Yeah, but I'm not!
Logged
I agree with Urist. Steampunk is like Darth Vader winning Holland's Next Top Model. It would be awesome but not something I'd like in this game.
Unfortunately dying involves the amputation of the entire body from the dwarf.

Infiltrator

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #13 on: July 20, 2009, 05:17:58 pm »

I take back my earlier complaints, I didn't realize you were organizing a central megathread for all pathfinding issues.  I approve.  Good organization too!

You're fortunate I'm over my quota for snide for the week :-p
Already?! It's only Tuesday!

Yeah, but I'm not!
You're not fortunate? :P

I take back my earlier complaints, I didn't realize you were organizing a central megathread for all pathfinding issues.  I approve.  Good organization too!
I'm glad. :P

And thanks for all the nice comments, but what would be much appreciated is provision of data and/or links. :P
Like I said, I'm a newcomer, I don't remember that thread with a funny name from a year ago that had some intricate details that needs to be referenced here. :P

I specifically put that unless a "my personal issues" heading for a reason. :P
Oops, I'd missed that particular spoiler-expansion section, after going down and reading (or at least skimming!) the whole lot.

Plus I appear to be typing far too much, today, when just meaning to type basic points/responses, but that's not an issue restricted to this thread/forum.  :D
You may have, yes. I am reorganising it as I go, and I didn't have it inside a spoiler section earlier, so you may not have seen the title before reading it.

And for this thread, lots of typing is probably good. :P
If anything's too long, it can always be summarised. Expanding is a lot harder. :P
Logged
GENERATION 25:
The second time you see this, copy it into your signature on any forum and add 2 to the generation. (Slight mutations allowed)
Sociopathic experiment.

awdball

  • Bay Watcher
    • View Profile
Re: Pathing and Connectivity
« Reply #14 on: July 20, 2009, 05:26:26 pm »

One tweak to the existing pathing that I think would help the sanity of miners is some variation on pretending the square to be mined is pathable and or pathing backwards from the square to be mined to the square the dwarf is in. Depending on the specifics of Toady's implementation either might allow the dwarf to find the nearest face to mine from.

AWDBall
Logged
Pages: [1] 2