Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Sunken

Pages: 1 ... 8 9 [10] 11 12 ... 20
136
DF General Discussion / Re: Anouncing The PathFinder Project
« on: November 03, 2009, 03:22:45 am »
A question not yet raised in this thread: what heuristic to use.  One issue with traffic designations is that if you're actually using them heavily, the standard heuristic (euclidean distance) can make you sad: it assumes it costs 1 to cross each unit distance, when in fact it probably costs 2 or maybe 25.

It's not clear to me how to improve on that, but maybe someone has an idea.
It's a tough one. I think it will be extremely hard to come up with a heuristic that is more efficient than the obvious one - not Euclidean, but
max(abs(dx), abs(dy))-min(abs(dx),abs(dy)) + sqrt(2)*min(abs(dx), abs(dy)) + abs(dz)

...and still remain both admissible and monotonic.
I think we're probably stuck with this heuristic. We'll have to concentrate on making the tree itself more efficient, through using good segmentation of the map. And maybe using caching, though I'd go for that only as a secondary.

137
DF General Discussion / Re: Anouncing The PathFinder Project
« on: November 03, 2009, 03:17:59 am »
You obviously don't mean the same by rectangles as I do. I mean unoccupied rectangles - unoccupied being the prerequisite for search-less pathing such as the Bresenham algorithm. You allow obstacles in your rectangles. It would take 11 unoccupied rectangles.

Which solution has more overhead in terms of memory cost:

11 rectangles
5 regions

?
5 TCZs have more overhead than 11 rectangles, obviously. But I will stick my neck out and claim most fortresses don't look much like the example. Only testing in the wild will tell which is the more practical.

138
DF General Discussion / Re: Anouncing The PathFinder Project
« on: November 03, 2009, 03:16:05 am »
But all we seem to be using of convexity is that there is a closed-form solution for the cost from one tile in the region to another, looking just at their coordinates -- this is a larger class than what you'd normally call convex.  For example, TCZs have this property when diagonals are the same cost as the other directions (which is not the case here, but it might still form a good approximation).
Exactly. "Convex" doesn't have an unambiguous definition on discrete sets, AFAICS, but if one can define a closed-form next-step algorithm (math people would probably use "ordering" here somehow), then a convex region is one where that algorithm takes you on a path that never leaves the region to your goal.
TCZs are just a special case, more general than more natural algorithms that just step in a straight line for the goal, doing no obstacle avoidance at all (such as Bresenham).

Indeed, the silly-move strategy is not guaranteed to produce the shortest path within a TCZ with obstacles - it can be a factor sqrt(2) inefficient in really contrived cases.

But note - even if we form our zones as TCZs, we don't have to use silly-move to actually path-plan within them. We can use A*, and we'll know the search will not run into the usual traps with doubling-back. That will give us an optimal path with the benefits of a more or less intelligent zone decomposition.

139
DF General Discussion / Re: Anouncing The PathFinder Project
« on: November 02, 2009, 05:08:53 pm »
I actually think that A* rectangles will be larger than TCZs. TCZs need a region of a) uniform cost and b) trivial complexity. How many TCZ regions (and purely A* regions) will be necessary to span the following design:
Code: [Select]
###########
a #   #   #
# # # # # #
# # # # # #
#   #   # b
###########
Spoiler (click to show/hide)
You obviously don't mean the same by rectangles as I do. I mean unoccupied rectangles - unoccupied being the prerequisite for search-less pathing such as the Bresenham algorithm. You allow obstacles in your rectangles. It would take 11 unoccupied rectangles.

To be clear:

axis-aligned obstacle-free rectangles
subset of
convex obstacle-free zones
subset of
TCZs

and

convex obstacle-free zones
subset of
arbitrary axis-aligned rectangles
subset of
arbitrary connected zones

The first three types of zone have a constant-per-tile complexity guarantee through their definition. The last two don't (I guess it's order-of-total-tiles, worst case), unless you add some further restriction (which is certainly possible).

Quote
I am thinking though that pure rectangles may not be best. I was thinking that some sort of subtractive geometry might be efficient. We could define zones as "all of this rectangle except for those in the following rectangleszones". This could be represented as a "tree" (actually more of an acyclic graph -- since I would allow nodes to have multiple parents) where zones further down the "tree" have higher priority over the ones higher up. To determine what zone a node is, the algorithm goes down the path of the "tree" with zones containing the node until there are no zones further down containing the node. Pathing proceeds normally just using zones. This hierarchy is only used for determining a node's zone (though if we require zones to be completely contained in their parent zone: 1) we would have a multi-level hierarchy we could use to optimize pathing 2) the "tree" is a tree).
Can't say if this would work or not. It seems like it might be sensitive to changes in the map, the way quadtrees et al. are, and the diagonal-tunnel example I put forth a couple of posts ago applies here too. But these are just hunches on my part. If you think it will work then you should try it out.
Quote
Even assuming that computing that polynomial (leaving out the sqrt) is not too expensive, I think that would tend to make the algorithm try suboptimal paths first? Because that formula is not, in fact, the straight-line distance to the goal as the dwarf would walk in an open world. I'm not sure about that.
Anyway, it means adding computational complexity for an essentially cosmetic effect. It would work, though, and could be tried easily enough on top of any other approach AFAICS.
The way I mean it, it shouldn't cause suboptimal paths to be tried first. I realize this formula isn't the distance as the dwarves see it (for them its actually max(dx,dy,dz)). It's actually more of a tie-breaking rule. We already have the cost (which in A* is equal to cost so far plus estimate of cost to go) for each candidate node. All I'm suggesting is if there is more than one node with the same cost, they can be sorted based on Euclidean distance (purely for aesthetic reasons).
Yes, as a tie-breaking rule it would do the trick, though I'm not sure how you'd make sure the modification doesn't go beyond pure tie-breaking. But it's probably not a hard problem to solve.

And the cost isn't max(dx,dy,dz) (or max(abs(dx), abs(dy), abs(dz)), if one is to nitpick), but actually:
max(abs(dx), abs(dy))-min(abs(dx),abs(dy)) + sqrt(2)*min(abs(dx), abs(dy)) + abs(dz)
"straight bit plus diagonal bit plus vertical". Or at least I think so - I think movements in the "vertical diagonal" aren't possible.

140
DF General Discussion / Re: Anouncing The PathFinder Project
« on: November 02, 2009, 02:21:10 pm »
Starver, I just skimmed over your description; it's too late in the evening to get deeply into it for me (spend much of my days reading and my brain gets tired...) but essentially, you're proposing a tree-like decomposition into convex zones, right? A non-overlapping, mutually exclusive decomposition?

Path-planning-wise this will have all the attributes of a convex subdivision, which has been part of the discussion for a bit now: trivial to path across, larger and thus potentially more efficient than rectangles; smaller and (or so I maintain) potentially less efficient than TCZs.
And you're suggesting a structure to create and maintain that convex subdivision, correct?

I'm doubtful as to the tree approach, though. Won't it be inefficient wherever the edges of the convex zone runs in the diagonal direction? This zone
Code: [Select]
#####   
####   #
###   ##
##   ###
#   ####
is convex enough but would not benefit from the hierarchy you propose, I think? Correct me if I'm wrong.

141
DF General Discussion / Re: Anouncing The PathFinder Project
« on: November 02, 2009, 02:05:50 pm »
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.
OK, amortized over the entire path you are correct, since silly-move has to either check the next step at each step, or precompute the entire path at cost O(N). A* has to do the latter.
A* will incur more overhead as you say.

The main point is not that silly-move is cheaper, but that it is part of the definition of a TCZ, which in turn guarantees that both movement strategies will find the path. Larger zones - you'll have to find another proof of linear complexity. And you have to come up with a way of creating those larger zones.

Quote
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.
Yes, that was the whole point of TCZs. They are strictly larger than convex zones or rectangles, while guaranteeing a constant-per-step complexity intra-zone. Again, even larger zones would be better, but not if that means losing intra-zone complexity guarantees.

Quote
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.
Rectangles will always be smaller than TCZs, that's what I've been trying to tell you. I'd still use rectangular bounding boxes to speed up TCZ lookup though.
And to my mind TCZs will be better at isolating chokepoints than rectangles. The biggest problem with TCZs is their tendency to overlap each other.

Quote
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.
Even assuming that computing that polynomial (leaving out the sqrt) is not too expensive, I think that would tend to make the algorithm try suboptimal paths first? Because that formula is not, in fact, the straight-line distance to the goal as the dwarf would walk in an open world. I'm not sure about that.
Anyway, it means adding computational complexity for an essentially cosmetic effect. It would work, though, and could be tried easily enough on top of any other approach AFAICS.

142
DF General Discussion / Re: Anouncing The PathFinder Project
« on: November 02, 2009, 11:03:17 am »
Sounds like you're on your way to inventing the TCZ ;-)

143
DF General Discussion / Re: Anouncing The PathFinder Project
« 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.

144
DF General Discussion / Re: Anouncing The PathFinder Project
« 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.

145
DF General Discussion / Re: Anouncing The PathFinder Project
« 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.

146
DF Suggestions / Re: 'Autodecompose'
« on: November 01, 2009, 03:19:57 pm »
None of these suggestions need to exclude the others, of course...

147
DF General Discussion / Re: Anouncing The PathFinder Project
« on: November 01, 2009, 07:21:02 am »
Planning movement within a rectangle is not a problem, no matter which algorithm you select. Nor is it within TCZs, using silly-move. The computational costs for these are all absolutely negligible, I think.

The problem is the search. What is needed is a reduction in branching factor and search tree depth (and a good heuristic). And it's my belief that TCZs will have a better impact on these key factors than rectangles will.

But it's true that in principle it would be possible to mix zones of different types. It would require more programming work, and a disciplined, modular structure, but it's not infeasible.

148
DF General Discussion / Re: Anouncing The PathFinder Project
« on: November 01, 2009, 06:55:34 am »
Not that moving targets are really at issue here. Short-distance pathfinding is not what's costing us FPS.

149
DF General Discussion / Re: Anouncing The PathFinder Project
« on: November 01, 2009, 06:53:47 am »
Made an edit, but too late. Pasting my rebuttal here:

Still, Bresenham will require the storage of the d parameter, and the final path will not actually cost any less than the silly-move one; it will just distribute the diagonal movements differently. Plus, it disallows TCZs (as presented by me, as opposed to rectangles or other strictly convex regions) and, as you say, isn't optimal with moving targets.

150
DF General Discussion / Re: Anouncing The PathFinder Project
« on: November 01, 2009, 06:22:41 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

2: As for costs, you're comparing a cached version of your algorithm with a non-cached version of mine. Hardly fair! Silly-move can be cached just as easily as a Bresenham path, except it would be pointless since computations are far less expensive than memory access nowadays.
Edit 2: Heh, scratch that too, I misread your claim.
Still, Bresenham will require the storage of the d parameter, and the final path will not actually cost any less than the silly-move one; it will just distribute the diagonal movements differently. Plus, it disallows TCZs (as presented by me, as opposed to rectangles or other strictly convex regions) and, as you say, isn't optimal with moving targets.

Pages: 1 ... 8 9 [10] 11 12 ... 20