quote:
Originally posted by 0x517A5D:
<STRONG>(And, as a programmer, I know how terrible it would be to run an A* search between every object and the target square just to generate a list.)</STRONG>
You don't need to run an A* search. Instead:
Using our existing 'rough distance measurement' (ignoring walls), measure the distance from our starting point to each staircase. This is extremely fast (just take their XY coordinates and do some math), so we can do it for all staircases and ramps, and, using this, produce a very rough estimate of how long it would take us to reach any given staircase/ramp on any given floor.
Then, on each floor, calculate the rough distance each item is from the floor's staircases, adding this to the rough distance from before. Again, while this sounds like a lot of work, it is quick and easy, since we're not actually looking at walls or anything, just a few staircases.
The resulting map won't be perfect, but it will be as good as anything we had in the old version (better, in some ways), and it won't be fooled by the Z-axis.
If you want to be clever, you could create and store a map of the exact distances between all staircases and ramps using A* - those don't change much, so it'd be easy to do once and maintain, and we could then use it to produce very accurate distance measurements (since we'd only need to take a rough guess to the current floor's staircases, and from the staircases at our destination floor.) Exact distances between the staircases a few other generally 'static' things, like the trade depot and various stockpiles, could be calculated and stored as well. That way, we'd only need to approximate the occasional stray item, and only as close as the nearest staircase.