Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 16 17 [18] 19 20 ... 43

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

zchris13

  • Bay Watcher
  • YOU SPIN ME RIGHT ROUND~
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #255 on: November 01, 2009, 08:59:00 pm »

Searching long branching hallways with a central stairwell has always been a major issue.  The zones could really help with this, because hallways are long zones with (usually) doors (fixed entrances and exits) to rooms. You would not have to have the walkers "walk" all the way down the hallway, if you knew the approximate pathcost to each of the doors.  You would only have to skip to the doors, add the pathcost, and go from there (with some sort of "oh look that's the totally wrong direction, don't need to check that broom closet") for each of the hallways.
Logged
this sigtext was furiously out-of-date and has been jettisoned

Sunken

  • Bay Watcher
  • Wabewalker
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #256 on: November 02, 2009, 04:04:43 am »

As far as the zones and branching goes, however, I'm not so much of a fan of the TCZ's that Sunken is proposing. I don't see the advantages of silly-move over A* for the scenarios silly-move is applicable for outweighing the flexibility of A*. Additionally I think we can do better if we allow for zones that do not satisfy TCZ (such as a windy passage that doubles back), but which are trivially pathable with A*. I also think that zones should be 3D since this allows for similar windy passages in the z-direction (and the sky could be one gigantic zone).

There's a trade-off: The more complex the intra-zone navigation is allowed to be, the larger the zones can be -

straight-line -> convex zones
silly-move -> TCZs
A* -> more convoluted zones (entire maps, in fact)

We simply have to experiment to see which trade-off  is most beneficial.
I'll say this, though: There has been no automatic cut-off criterion proposed for A* zones. As I just said, they can be as big as you want - but unlike the other two, the intra-zone pathing becomes more and more expensive for A* as the zones grow. Silly-move and straight-line are constant-time no matter how big the zone.

So, saying that we should use A* inside zones just begs the question - what zones to use? I thought up TCZs because they seemed a reasonable compromise.
Logged
Alpha version? More like elf aversion!

Draco18s

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #257 on: November 02, 2009, 06:57:29 am »

I'm just popping in now to point out that in a tile based game, convex zones are rectangles.  Any other shape ceases to be convex.  Diagonals in a square area are an odd case, as the square the line passes through may or may not be traversable (eg. diagonal movement around a corner).  Currently such diagonals are allowed at normal cost (1.4), but this may change.
Logged

Fieari

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #258 on: November 02, 2009, 07:25:32 am »

Why would diagonal movement change?  Toady went to some lengths to enable diagonal movement in the first place...
Logged

Sunken

  • Bay Watcher
  • Wabewalker
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #259 on: November 02, 2009, 07:27:53 am »

I'm just popping in now to point out that in a tile based game, convex zones are rectangles.  Any other shape ceases to be convex.  Diagonals in a square area are an odd case, as the square the line passes through may or may not be traversable (eg. diagonal movement around a corner).  Currently such diagonals are allowed at normal cost (1.4), but this may change.
Here's a convex zone to disprove your claim:
Code: [Select]
##
####
####

Edit: I suppose you mean that a tiled world superimposed on Rē only allows (axis-aligned) rectangles. But that's a useless definition of convexity in a tiled world. I, and I think most others, have been assuming convex to mean "the shortest path from two tiles in the set lies in the set", where "path" is something a dwarf might follow.
« Last Edit: November 02, 2009, 07:34:28 am by Sunken »
Logged
Alpha version? More like elf aversion!

Starver

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #260 on: November 02, 2009, 09:22:38 am »

As for using bezier curves or other algorithms[...]

[Actually, the response of mine has been retro-ninjaed later, especially regarding the Bresenham function.   Which I admit I never knew the name of.]
« Last Edit: November 02, 2009, 09:37:13 am by Starver »
Logged

Sunken

  • Bay Watcher
  • Wabewalker
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #261 on: November 02, 2009, 09:36:19 am »

Though I agree the smooth line does look better, with the current path costs it is a purely cosmetic issue and must, I think, take a back seat to efficiency. In other words, if it should turn out TCZs or some other Bresenham-unfriendly zoning method is the more efficient choice, we'll have to go with the uglier diagonals.

Now, if costs were changed to make the staggered diagonal actually cheaper than the alternatives, then that would be a different story.

As for curves - a curve is never the shortest way (in Euclidean space) and so again I think aesthetics must give way to efficiency.
Logged
Alpha version? More like elf aversion!

Starver

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #262 on: November 02, 2009, 09:40:07 am »

You got in there just before I decided to retract the post. :)

As for curves - a curve is never the shortest way (in Euclidean space) and so again I think aesthetics must give way to efficiency.

Although because of the non-Euclidean nature, a 'nice' curve can be no less efficient than a drastic non-curve.  (As can be a total zig-zag, of the kind we might actually use in Adventure mode while trying to sweep more of the field...)
Logged

Starver

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #263 on: November 02, 2009, 09:47:29 am »

1: You're working from an incorrect assumption. Diagonal movement and orthogonal movement cost the same in DF.
Edit: Scratch that, there's a sqrt(2) factor in there
Is there?  Oooh, I assumed it was equal in all eight basic directions.

Might put the scuppers on any assumptions I've made, if this is true.  Of course, if anyone was going to make this matter, Toady would.

(Not that it would matter if a route was 10E,5NE or 5NE,10E or 5x(2E,NE), but it would mean that 20E would be quicker than 10x(NE,SE) or 5x(2NE,2SE) or other versions.  Now, how does one test.  Actually, never mind, for now I'm not too bothered.  Just speculating.)
Logged

Starver

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #264 on: November 02, 2009, 10:07:03 am »

I'm just popping in now to point out that in a tile based game, convex zones are rectangles.  Any other shape ceases to be convex.  Diagonals in a square area are an odd case, as the square the line passes through may or may not be traversable (eg. diagonal movement around a corner).  Currently such diagonals are allowed at normal cost (1.4), but this may change.
If you enforce wossisnames[1] algorithm, then a diagonal in a zone might preclude a 'convexity', as the 'ideal stagger' hits the wall, but otherwise shouldn't matter.

For example:
Code: [Select]
            ########
       ######b    a#
########c          #
#d                 #
#                  #

a->d 17W,2S which would be a sum of 15W,2SW, or "ideally" 5W,SW,5W,SW,5W, which would hit the wall next to 'c'. (This was quickly rendered in ASCII, I may not have made the wall stagger B-algorithmically correct!  It might more correctly miss the wall.)  But it could be made to sidestep SW earlier and delay one of the W-steps.  To equal weight (with or without the root-2 cost l;evied against a diagonal).

b->d and c->d would be required to start with the SW movement (and the route from b may need to premeturely enact a second SW, compared to the B-algorithm's idealisation), but to the same equality.  That shape would still be topologically convex in all respects.  Treat the 'inconvenient' corners on the diagonal wall much the same as inconvenient single-square 'step-around' blocking elements in the middle a zone.

Ironically, if the 1.4 weighting exists, then a straight orthagonal path that has to make a diagonal-and-back 'jink' around an obstruction on the path will cause more problems to (strict) convexity than otherwise.  Although minimal in the grand scheme of things.

[1] Begins with a 'B', forgotten it already.  Sorry.
Logged

Shades

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #265 on: November 02, 2009, 10:21:19 am »

Might be able to achieve some of the 'nice' curves, the ones that are the same total length at least, by when performing the A* search you prioritise the squares in the current direction of movement.

As there is only 8 squares in the plane of movement the combinations for order of testing are few and can probably be handled cheaply with a lookup against the links (rather than processing links in order).

I have no idea if it would get the effect you desired, or how much extra processing it would really be but it would be a very minor change to any of the A* implementations (or any graph based search) and so easy to test.
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

Starver

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #266 on: November 02, 2009, 10:47:49 am »

For example:
Code: [Select]
            ########
       ######b    a#
########c          #
#d                 #
#                  #

a->d 17W,2S which would be a sum of 15W,2SW, or "ideally" 5W,SW,5W,SW,5W, which would hit the wall next to 'c'. (This was quickly rendered in ASCII, I may not have made the wall stagger B-algorithmically correct!  It might more correctly miss the wall.)[...]

Actually, re-reading my own item, the whole point is that corner-to-corner of the region should have been a 'regular' stagger, the wall that bounds it is beyond the limit.  However consider the zone bounded by...
Code: [Select]
                    ###
#####################a#
#b         c          #
#                     #
#             d       #
#######################
...that would be as much convex as the rectangle minus the alcove, given that no shorter route exists between all points within than the shortest route that must avoid the boundary.  The route a->b would have to be SW, then a number of Ws, but would not be longer than the stagger that travelled 'through' the wall then emerged at or around 'c'.

Of course, if 'c' was an obstacle, then the 1.4 weighting would cause minor problems (without, one might even stretch the definition to still be convex), and ditto if there was a further alcove in the wall at 'c'.  But (at least in the latter case) it would be a trivial matter of making the 'a' or 'c'-adjacent alcove a separate 1x1 zone attached to the main zone.  For a "'c' is an obstacle block", then if your algorithm bothered about the weighting disadvantage you might be forced to split the zone.  Either straight down (shortest distance) or across to hypothetical obstacle 'd' should that also spring into existence.

But that's all... well, a different solution/direction-of-solution to what is being worked on with the A* algorithm stuff, as far as I can tell, so this is just waffle on my part.
Logged

Sunken

  • Bay Watcher
  • Wabewalker
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #267 on: November 02, 2009, 11:03:17 am »

Sounds like you're on your way to inventing the TCZ ;-)
Logged
Alpha version? More like elf aversion!

Starver

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #268 on: November 02, 2009, 11:40:30 am »

Sounds like you're on your way to inventing the TCZ ;-)
Well, to be honest I had invented something prior to hearing of the TCZ that was very TCZ-ish, but then came in after the weekend/night-off to see almost all of my considerations[1] mentioned.  (Straight off, I must have skimmed over what TCZ was, and thought the "C" was for "Convex", but rewound after a while when I decided I really needed to know the title.)

But even back then I had assumed it was to be a Bresenham line on all sides (albeit that there were several possible B-lines, or rather that various possible B-line segments could be adopted as the zone border, where it wasn't a fully constrained border, just a path between corners as defined by other constraints.  And I'd also never considered the possibility of single blocking cells in the centre not (necessarily) preventing a zone's trivial connections.  To my eye, it would have forced the bissection of a potential zone.

[1] Tell you what, here's something of what I'd composed.  This was not a finalised version (appears to have a few BBCode-inaccuracies, being composed off-line), but contained the basis of the "from the ground up" conglomeration of tiles into zones, which would have been maintained but in turn grouped as sub-zones, and included the stipulation that zone borders overlap (by one tile) with relevant adjacent zone borders, and that zone-group edge-zones overlap with all relevent adjacent zone-groups' edge-zones (i.e. copying) which I felt was an inefficiency of storage that could be made up for by the possibility of giving better routings between zones/meta-zones/meta-meta-zones/etc.:
Spoiler (click to show/hide)
Logged

shadow_slicer

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #269 on: November 02, 2009, 12:00:05 pm »

There's a trade-off: The more complex the intra-zone navigation is allowed to be, the larger the zones can be -

straight-line -> convex zones
silly-move -> TCZs
A* -> more convoluted zones (entire maps, in fact)

We simply have to experiment to see which trade-off  is most beneficial.
I'll say this, though: There has been no automatic cut-off criterion proposed for A* zones. As I just said, they can be as big as you want - but unlike the other two, the intra-zone pathing becomes more and more expensive for A* as the zones grow. Silly-move and straight-line are constant-time no matter how big the zone.

So, saying that we should use A* inside zones just begs the question - what zones to use? I thought up TCZs because they seemed a reasonable compromise.

I'm not sure that intra-zone pathing is difficult for A* than it is for silly-move for the cases where the two are applicable. If your silly-move algorithm is simply "move to the tile that is closest to the destination," then A* will have similar complexity since the only tiles A* would consider are the same ones the silly-move algorithm would (So both are algorithmic on the order of the zone size). A* has some additional overhead since it handles non-uniform costs, but this does not affect the algorithmic complexity.

Having smaller zones can actually decrease performance as well. As zone size decreases, the ratio "surface area" (number of external links) to the enclosed volume increases linearly (or is it even superlinearly?). In order to perform A* routing over the set of zones, the source link must know the cost to each of the other links in the zone. This means that the required calculation and storage grows as O(n^2) in terms of the number of links, resulting in the total algorithmic complexity increasing as O(n^3) in terms of the "smallness" of the zone. Note that this will be true regardless of what method of pathing is chosen inside the zones.

I'm not saying that the zones should be too large. A large zone with lots of chokepoints or doubling back or something like that would perform horribly, regardless of the pathing algorithm chosen. There definitely needs to be a tradeoff between zone size and complexity. I still haven't found a good algorithm to define the zones. All I really have so far is that the edges should follow chokepoints as much as possible to reduce external links. And I would probably use rectangular prisms as zones since this makes it easier to determine which zone a tile belongs to.

Edit: (instead of posting again)
Also, A* can be modified to produce the diagonal pattern that several posters have suggested seems more natural. If A* was adjusted to order (ascending) candidate nodes with equal heuristic cost by "sqrt(dx^2+dy^2+dz^2)", where dx, dy, and dz are the differences between that node's x,y, z and z positions to that of the destination, the paths found by A* would look like those "straight" lines.
« Last Edit: November 02, 2009, 12:08:48 pm by shadow_slicer »
Logged
Pages: 1 ... 16 17 [18] 19 20 ... 43