Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 36 37 [38] 39 40 ... 43

Author Topic: Anouncing The PathFinder Project  (Read 98112 times)

Martin

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #555 on: March 16, 2010, 01:45:58 pm »

Jumping in a little late here, but I've done A* on a scale simliar to DF, with some of the same kinds of issues that DF has.

The approach I'd initially take is the hierarchical one - using certain elements to serve as reference points and build out a cache only using these points. The reference points would be:

door
stair
bridge
hatch
floodgate with mechanism
trade depot
etc.

I'd concentrate on the elements that the player can control (let the players interested in running massive fortresses design them with the pathfinder in mind), which routinely serve as chokepoints and are variable in state. This might also include workshops and stockpiles. Toady could even add the ability for the player to designate a reference point using the zone tool, or some such.

I overall agree with Teiwaz here. I wouldn't get obsessed with keeping this cache perfectly calculated for one main reason - we don't do that in real life, and because we know that actual travel costs in DF rarely match theoretical costs once the per-tile cost of traffic is included. IRL, we know we want to get to some place over there. Let's say we decide to ride our bike to the store. We know where we are going and we predetermine the reference points we're going to move through - street intersections and so on, but we don't have a priori knowledge of the state of these reference points. We know they presumably exist and we might have some probabilistic knowledge of their reliability, but that's about it. When we embark on our trip, we then discover the state of each of these reference points and recalculate accordingly. Construction may have a street blocked and we then recalculate from that observation to the next reference point on our journey. A gate might be locked and we recalculate again. Each time, we store that information so we don't repeat the mistake the next time. By and large, we use something that resembles a hierarchical A* system, but with different reference points, weightings and so on for each person.

So it's okay to have imperfect pathing, so long as it's imperfect in reasonable ways. Further, it's okay to embark with an incomplete path, so long as you have reasonable reference points - and that's where I'd put all the focus. There are some gameplay benefits to doing it this way, in fact. Right now, a dwarf can set a path across the map, only to find 99% of the way there that something has changed and they need to recalculate the path - perhaps having to retrace a huge distance. You can interrupt them by drafting them, etc. but otherwise they'll happily wander into a siege that every other dwarf is rapidly fleeing from. If there were a series of reference points the dwarf were navigating among, you'd only calculate a full path from the current position to the next reference point (much less A* work) and upon reaching that reference point, you'd check the updated state of the reference points in case something changed (such as someone pulled the 'stay inside' alarm), find the new optimal path from the cached reference distances (very fast), and then take the cached path. This way, the dwarf would adjust their path periodically based on new information arriving in the cache. By assuming that dwarves communicate such things freely, the game gets more realistic. Normally in a hierarchical A*, you don't have much discovery of new information in mid-path but with 200 dwarves running around, it's not unreasonable to have that occur, so let's call it a feature.

Each time a dwarf encounters a path which is no longer valid (a wall was put in, for example) the cache is updated for the distance between those two reference points (and possibly for all paths that share one of those two references, since there may be more), and dwarves will update accordingly.

One further benefit to this is that, memory permitting, the game can maintain two (or more) different sets of caches - one for dwarves and one for enemies. Dwarves will know all the shortcuts, but enemies should not, so their cache should be incomplete. Early sieges and squads may bumble about the place, but each encounter will fill in the cache a little more and cause them to act more efficiently. Depending on how memory efficient it is (it can even be saved to disk since it's only periodically invoked) different caches can be in place for gobbos, orcs, etc. so each one can have their own knowledge of your site and provide the player with differing behaviors, all for a relatively low cost. Further, species with different abilities would have caches better suited to their abilities.

Memory permitting, one other bit of data can be accumulated to influence pathing. In addition to the theoretical travel cost, the real cost can be stored for each reference node pair. The theoretical cost to go from A to B might be 100, but if it's a heavily travelled route, the last real cost might be 1000 as dwarves constantly climb over each other. That cost could be factored into the algorithm and also discounted over time so that as time passes, the stored real cost naturally declines, encouraging dwarves to try the route again. Again, this is more similar to how people behave.

Personally, I'd encourage people to embrace a slightly sloppy and fast solution over an ideal one.

Sizik

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #556 on: March 16, 2010, 01:46:24 pm »

It just occurred to me, does Kobold Quest use pathfinding in any way similar to DF?
Logged
Skyscrapes, the Tower-Fortress, finally complete!
Skyscrapes 2, repelling the zombie horde!

Draco18s

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #557 on: March 16, 2010, 01:49:02 pm »

It just occurred to me, does Kobold Quest use pathfinding in any way similar to DF?

I think so, yes.  But its not dynamic.
Logged

bombcar

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #558 on: March 16, 2010, 03:41:49 pm »

It should be possible to do "group" pathfinding.

If I have 20 dwarves sitting in the meeting area, and the designate 20 stone to be dumped, each dwarf paths to the stone individually.

But if the stones are near each other, in theory the "group" could path to the room, and then split up.
Logged

Martin

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #559 on: March 16, 2010, 05:50:13 pm »

It should be possible to do "group" pathfinding.

If I have 20 dwarves sitting in the meeting area, and the designate 20 stone to be dumped, each dwarf paths to the stone individually.

But if the stones are near each other, in theory the "group" could path to the room, and then split up.

That's harder than it seems as the game doesn't realize that it's given 20 jobs at a similar location to 20 different dwarves starting at a similar location. If a hierarchical pathfinder can be worked out, that'd take care of much of the problem. In what I described, you'd make the meeting area a reference point, so half of the pathing solution would now be done. The other end could be dicier, but then the idea of the interruptible a* could help. If it turns out that paths tend to clump in that way, hold onto the last path nodeset (or the last few) and see if the destination lands in that nodeset. If so, just use that information recently calculated. If those search nodesets can be kept small due to a good hierarchical approach, then it's easier to hang onto them for a bit. Not sure how much Toady can trade memory consumption for CPU, but it seems to me he can afford a fair bit given the current state of things. A lot of these things are easily parallelizable as well.

Toady really needs libdispatch to be widely deployed. That'd be perfect for him to knock these things out. Geeks can read about it here (Just the 2 pages on Grand Central Dispatch). Each job assignment would spin off into its own thread, match it to the dwarf, do the pathing, and off we go.

Teiwaz

  • Bay Watcher
  • [BABYSNATCHER]
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #560 on: March 16, 2010, 06:01:22 pm »

I don't think it's very realistic to expect players to set up pathfinding routes for their dwarves. The forum would just get flooded with people asking why their swarves aren't doing any jobs. This should be done proceedurally by the game. Storing the zones efficiently might be a problem, but generating them and figuring out when to update them would be trivial. (Dwarf fortress already does a simplified version of this with its connectivity map)
Logged

Martin

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #561 on: March 16, 2010, 06:09:23 pm »

The game already provides a means to set up pathfinding routes. I'm not suggesting that players would be responsible for doing it, just that if an experienced player wanted to drop a reference point out where they do a lot of tree cutting or something, having the capacity to do so wouldn't be a bad thing.

Andir

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #562 on: March 16, 2010, 07:16:02 pm »

The game already provides a means to set up pathfinding routes. I'm not suggesting that players would be responsible for doing it, just that if an experienced player wanted to drop a reference point out where they do a lot of tree cutting or something, having the capacity to do so wouldn't be a bad thing.
It's not unlike dropping a flag, beacon or lighthouse in real life.  In fact, I think it would add a little bit of cool realism to have some sort of beacon system but I understand the above point.  Some players wouldn't.
Logged
"Having faith" that the bridge will not fall, implies that the bridge itself isn't that trustworthy. It's not that different from "I pray that the bridge will hold my weight."

Martin

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #563 on: March 16, 2010, 08:32:43 pm »

Some players wouldn't.

Oh, most players wouldn't. But then most players don't use the traffic tools now, either, but I'm glad that they're available for those of us who do.

The reason I say to give the user the option to do is is that players will work out the system and find a way to put it there anyway. If bridges turned out to be automatic reference points (and they might now as part of the connectivity map) then the more advanced users will just plop a bridge out in the middle of nowhere simply to serve the pathfinding function. We do all manner of nutty things now to label levers, force dwarves or enemies down particular paths, get water or magma to do something we want it to do, and so on. I'm just suggesting that the game might as well formalize the interaction with the pathfinding system rather than leave players to come up with some goofy scheme.

Starver

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #564 on: March 17, 2010, 04:56:11 am »

One further benefit to this is that, memory permitting, the game can maintain two (or more) different sets of caches - one for dwarves and one for enemies. Dwarves will know all the shortcuts, but enemies should not, so their cache should be incomplete. Early sieges and squads may bumble about the place, but each encounter will fill in the cache a little more and cause them to act more efficiently.  [...]different caches can be in place for gobbos, orcs, etc. so each one can have their own knowledge of your site[...]  [saved to disk, etc]

While this isn't currently how knowledge is handled (in fact, it isn't) should it be so, a note I would add to this is that should the attack or siege result in every last man (/orc/goblin/elf/swarm of flies/whatever) dying, then knowledge gained during that attack is invalid (except maybe if there's something like a [psychic_link] tag on the creature raws?) and fortress access information reverts to none/the information known and 'loaded' up for the race just prior to their most recent arrival.

A good defence against invaders with this sort of limit (even if some live to head back on home) could be an ever-changing entryway.  Although you'd really have to apply it to caravans, as well.  In the absence of the extra-map dynamics promised in future versions anyway this could mean that caravans position their appearance on (accessible) parts of the edge closer and closer to the Depot location (as, of course, would invading forces better position themselves).  At least while it (and the route to it) was static.  Messing with the route causes delays for good and bad visitors alike.

But, of course, this leads to the whole idea of knowledge-based linkage asking whether dwarfs have their particular brand of omniscience at all, within their own fort.  Something that I think is being shied away from, given how unbalancing that would be to the player (assumed to be inspirational guidance, however bad they are playing or deliberately destructive are their guiding instructions to the current noble-of-disfavour) without making it a completely different aspect to the game (e.g. Adventure-mode fortress building).

(Also, you could argue about when information known by resident dwarfs also applies to immigrants.  Maybe the Hamlet/Etc Liaison's knowledge gets taken back after their visit, or a current native is tasked to wander over to within shouting distance to at least get them coming in the right direction... unless other changes to the game mean that immigrants can arrive after the total death of a fortress, when they have to start from whatever 'scratch' the game provides for your original settlers.  However, as I said, that's a different game.)





Sorry, it's been a while since I offered my opinion, and I can't really compete with those who have been able to actively participate with the coding tests (my own lie covered in virtual dust, and there's no point digging them out now, given their isolation of development w.r.t. the main PFP occuring here).
Logged

CobaltKobold

  • Bay Watcher
  • ☼HOOD☼ ☼ROBE☼ ☼DAGGER☼ [TAIL]
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #565 on: March 17, 2010, 10:19:25 am »

Yes, traders' wagons are 3x3 creatures, but they really travel around the "heart" of the wagon; you can see this in "D" mode. The starting wagon is treated as a creature in some ways; you can get error messages on some embarks that make this obvious.
This is why the fire trick works, indeed. It just does the DePOT-ACCESSIBLE thing for them to determine pathable space, I'm imagining.
What's the fire trick?
That, because of the way wagons are done, going up a one-thick ramp/wall/magma will put the donkeys through the magma, setting them on fire. But only going up.
Logged
Neither whole, nor broken. Interpreting this post is left as an exercise for the reader.
OCEANCLIFF seeding, high z-var(40d)
Tilesets

PencilinHand

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #566 on: March 17, 2010, 12:21:05 pm »

With all of the recent talk I feel it is necessary to quote myself:

...  Many things have already been discussed and it is just not an easy problem to solve.  Significant concessions and game shaping choices may need to be made to really improve the pathfinding. 

Knowing one way or the other would require Toady who has indicated he isn't really interested in this, at least currently.  ....

If you guys want to speculate that is fine with me, I would even be happy to see some code get produced from it.  However, anything needing the level of interactivity with the game that is being proposed would require Toady to implement it and maintain it.  We should not forget that Toady has said he would like to properly implement climbing and jumping, along with many other pathing algorithm breaking things.

Again, speculation is fine, but keep in mind that we are speculating over minutiae of an incomplete project.
Logged

ggeezz

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #567 on: March 17, 2010, 01:25:31 pm »

With all of the recent talk I feel it is necessary to quote myself:

...  Many things have already been discussed and it is just not an easy problem to solve.  Significant concessions and game shaping choices may need to be made to really improve the pathfinding. 

Knowing one way or the other would require Toady who has indicated he isn't really interested in this, at least currently.  ....

If you guys want to speculate that is fine with me, I would even be happy to see some code get produced from it.  However, anything needing the level of interactivity with the game that is being proposed would require Toady to implement it and maintain it.  We should not forget that Toady has said he would like to properly implement climbing and jumping, along with many other pathing algorithm breaking things.

Again, speculation is fine, but keep in mind that we are speculating over minutiae of an incomplete project.

The reason I bumped the thread quite a while back is that I thought Toady would be addressing the issue in the "not too far off" future.  I would imagine this speculation would be to his benefit when that time comes.  Not that he doesn't know what he's doing, but having had some people thoroughly hash out the topic is likely to be of benefit.
Logged

Shades

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #568 on: March 18, 2010, 03:10:45 am »


...  Many Significant concessions and game shaping choices may need to be made to really improve the pathfinding. 

I don't see why, I didn't the first time you mentioned it either.

We should not forget that Toady has said he would like to properly implement climbing and jumping, along with many other pathing algorithm breaking things.

And why would these break a decent algorithm, it's just more nodes in the node map with different costs and/or movement flags.
Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd

Draco18s

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #569 on: March 18, 2010, 08:26:18 am »

movement flags.

Storing that many movement flags per tile would be a huge amount of data, relatively.
Logged
Pages: 1 ... 36 37 [38] 39 40 ... 43