Bay 12 Games Forum

Please login or register.

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

Author Topic: Distance calculations ignore floors  (Read 920 times)

Seryntas

  • Bay Watcher
  • has created a masterpiece!
    • View Profile
    • RPGWW Forums
Re: Distance calculations ignore floors
« Reply #15 on: November 26, 2007, 01:54:00 pm »

quote:
Originally posted by Zombie:
<STRONG>Also, how on earth was this issue EVER the same in the 2D version? The problem is with the distance calculations along the z-axis. Seeing as the z-axis didn't exist in the 2D version, I highly doubt there was any problem even remotely like this in it.</STRONG>

We have the same trouble with distance ignoring floors as we've always had with distance ignoring walls.  If a dwarf is standing three squares away from something he can take for a job and there's another thing he could take that's two squares away on the other side of a one-square wall, no matter how much wall he has to navigate around to find a door or opening he will always go for the closer one.  It's exactly the same when the object the dwarf wants is in an adjacent space above his head: Regardless of the absurd roundabout path he needs to take to get up there (considering stairs), he'll prefer it to the same type of item two squares away on the same floor.

Logged
"Nectar and ambrosia are all the gods are allowed to eat in Greek mythology. In that way they're kind of like pandas. You know, in diet. From there the similarities break down." -my Greek Lit TA

Draco18s

  • Bay Watcher
    • View Profile
Re: Distance calculations ignore floors
« Reply #16 on: November 26, 2007, 02:01:00 pm »

People, like myself, who build forts using stairways the same way a hotel does would have a problem.  For instance, instead of heading to the bathroom in my suite, I'd walk down the hall, up the stairs and use the bathroom directly above me.

Building an a$$ load of stairs to accomidate the problem is basically saying dwarves can fly, and rocks float.  The shortest distance is a strait line and that rooms should a radius 3 sphere.

Or you're suggesting not doing any normal mining [d][d] but instead, make everything stairs [d], such that our corridors extend to all edges of the map, up, down, left, and right.  That way no matter where our dwarves go, they will have a direct line strait to it.

Now, if we did something that made sense, such as not allowing a dwarf to move from one stair tile to another, unless by changing z-levels (think about it, if there's a stair well that has two flights in it, you can't cross from one to the other) then it wouldn't be feasible, or even make sense to build stairs everywhere.

Also note that "item distance" to the z-level directly above (same x,y) is 0, not 1.  Two z-levels is also 0, as is 3, 4, 5, and 6 (try digging out a room several levels below your trade depot and shunting some stuff there).  "Help!  My dwarves run all the way to the west to grab a stone even though they went right past several one square to the north!"

Anthing that increases the pathing distance to a different z-level is fine by me.  Hell, even if it's "I need a rock, rock, rock, all the way over there...oh look, I'm standing on one, I'll use this one."

Logged

Yourself

  • Bay Watcher
    • View Profile
Re: Distance calculations ignore floors
« Reply #17 on: November 26, 2007, 02:40:00 pm »

The issue isn't so much a lack of stairs, but rather construction on a different level interfering.

For example, in my fortress, the workshops are all in a "tower" sort of formation.  I have 8 stairwells connecting all the workshop levels to the stockpiles.  When I was digging magma chambers to go below my magma forges and smelters, the stones generated were causing my stonecrafter dwarves to take a really long route into the chambers to grab the stones.  I couldn't connect my normal staircases to the chambers because then I would have flooded the entire lower half of my fortress with magma.  I ended up forbidding all the stones to stop it.

This raises another issue with some of the solutions we've suggested here.  Each level of a fortress isn't necessarily connected (and rarely is).  Keeping the distances to staircases won't account for the fact that different staircases lead to different sections that don't connect.  This makes a practical solution trickier.  Although one thing does come to mind.  DF can already compute whether or not your trade depot is accessible and display the accessibility of every tile.  Rather than a simple binary "can get there" or "can't get there" state, it could keep the path distance to each tile (and for efficiencies sake it could possibly only compute this value for tiles within a certain distance.

I do, however, agree that this isn't a bug.  The dwarves do exactly what they're supposed to; it's just that what they're supposed to do is rarely the best.

Logged

Nil Eyeglazed

  • Bay Watcher
    • View Profile
Re: Distance calculations ignore floors
« Reply #18 on: November 26, 2007, 03:49:00 pm »

quote:
Originally posted by Align:
<STRONG>But we'd have to dig through engraved floors!</STRONG>

Yup.  And to best reach areas nearby on the x-axis in a fort with predominantly north-south corridors, you'd have to dig through engraved walls.

Dump an anvil on your engraver's head, or plan ahead, or just sit back and enjoy some good ol' DF-style mayhem, the kind that makes the game fun.  Z-axis is no different than x or y.

[ November 26, 2007: Message edited by: Nil Eyeglazed ]

Logged
He he he.  Yeah, it almost looks done...  alas...  those who are in your teens, hold on until your twenties...  those in your twenties, your thirties...  others, cling to life as you are able...<P>It should be pretty fun though.

Nekojin

  • Bay Watcher
    • View Profile
Re: Distance calculations ignore floors
« Reply #19 on: November 26, 2007, 06:03:00 pm »

quote:
Originally posted by Draco18s:
<STRONG>Also note that "item distance" to the z-level directly above (same x,y) is 0, not 1.  Two z-levels is also 0, as is 3, 4, 5, and 6 (try digging out a room several levels below your trade depot and shunting some stuff there).</STRONG>

This, right here, is the crux of the problem. The issue wouldn't be so significant if the z-axis was actually used in calculating the distance, but right now a coordinate of 12,12,12 is figured exactly the same as a coordinate of 12,12,0. If we're doing a quick calculation from, say, 0,0,0, then 12,12,12 should be 12 spaces further, not the same distance.

I agree that people should think "more three-dimensionally." Make multiple stairways throughout your Fortress to allow easier access to different levels of your Fortress, and to allow quicker transit between important points on different levels.

Many of my fortresses have one central stairwell (usually a 2x2 series of up/down stairways), with most of the major "points of interest" in the Fortress being situated around that axis. Sometimes this is by design, sometimes it's by necessity - when my main water source is 13 floors down and on the other side of the map, a lot of digging is going to be called for, and I don't have the time to set up an elaborate screw pump system. So, I tunnel down, and in the process make a radial room setup that favors use of the stairwell. Since it's 2x2, that's the functional equivalent of a 4-wide hallway - plenty of room for passing.

Logged

Yourself

  • Bay Watcher
    • View Profile
Re: Distance calculations ignore floors
« Reply #20 on: November 27, 2007, 01:19:00 am »

quote:
Z-axis is no different than x or y.

Except for gravity; but that's irrelevant to this discussion.  I guess it'd be kind of funny to see all the dwarves falling to the right.

Logged

julius

  • Escaped Lunatic
    • View Profile
Re: Distance calculations ignore floors
« Reply #21 on: November 28, 2007, 04:14:00 pm »

quote:
Originally posted by Align:
<STRONG>If you knew it was reported before why did you post a new topic?</STRONG>

Because it was buried inside another bigger bug report and I just wanted to make sure it wasn't lost.  Sorry to offend.

I am not going to comment on whether it is a bug or not or whether I think a fix is required-- I'm just reporting an oddity which Toady can fix or not as he wants to.  I do think, however, that building stairways every which way is not always practical.  In my initial example I could dig a staircase from the trade depot straight down to my forge complex and thus the distance to shift bars would truly be '6'.  But then my fortress would have a second entrance that I would need to defend.

In general ignoring floors and walls when calculating distance is more than compensated for with the ability to move diagonally and vertically, so I'm not gonna press for any sort of immediate solution.

Logged

Keldor

  • Bay Watcher
  • Blood for the blood god!
    • View Profile
Re: Distance calculations ignore floors
« Reply #22 on: November 28, 2007, 10:41:00 pm »

Think about it - which item is easier to access?  One five floors straight above you or one 5 squares to the east?  Unless you just happen to be standing on a staircase, the one on the same floor is almost certainly easier to reach.  Hence, adding a bias to Z distance when guessing which item is easiest to reach makes sense.  Besides, dwarves probably don't like hauling up and down many flights of stairs.  Would you?  XD

The bias wouldn't prevent them from taking items from different Z levels, it would just make them appear somewhat further away than simple vertical distance would indicate.  Thus, they might perfer the item 7 squares to the west and 1 square down over the one 5 squares straight down from them.  They would still perfer the item 2 floors up from them and 6 to the south over the one on the same floor, but 147 squares to the north!

Think of in your own house - is it easier to grab something 10 feet away on the other side of the room, or 10 feet above you on the second floor?

Logged
If ignorance is bliss, why are my dwarves all tantruming?

Yourself

  • Bay Watcher
    • View Profile
Re: Distance calculations ignore floors
« Reply #23 on: November 28, 2007, 11:21:00 pm »

The main thing is that there is more open space horizontally than vertically.  It will almost always be easier to cover some horizontal distance than a vertical one since stairs aren't built every other tile.
Logged

Akjosch

  • Bay Watcher
    • View Profile
Re: Distance calculations ignore floors
« Reply #24 on: November 29, 2007, 08:11:00 am »

quote:
Originally posted by Nil Eyeglazed:
<STRONG>Z-axis is no different than x or y.</STRONG>

In Dwarf Fortress, it is. This is the whole point of the thread, that DF threats distance calculations over the Z-axis differently than for the other two.

Besides, try it out - compare what kind of FPS you get while staying on one horizontal plane to the one you get making a fortress vertically. I'm trying something like that right now, carving a roughly 50x50 tiles big artificial lake all the way to the bottom, and the lags are getting really annoying.
here.

Logged

Anjey aka PM

  • Bay Watcher
    • View Profile
Re: Distance calculations ignore floors
« Reply #25 on: November 29, 2007, 10:51:00 am »

Well searching for closest stone/etc. for workshop can be somewhat extended so code will check real path length for each found object and if it's more than twice farther than straight distance to it -- look for another (something schematic below)

code:

FoundObject = undef;
Distance = 1;
ShortestPath = -1;

do {
 foreach Item in GetItemsOnDistance(Distance) {
   PathLengh = GetPathLengh(Item);
   if (PathLength <= Distance*2) { // Well real path only two times longer then straight distance -- acceptable
     FoundObject = Item;
     return FoundObject;
   } elsif ((PathLength < ShortestPath) || (ShortestPath < 0)) { // This one is closer then previous
     FoundObject = Item;
     ShortestPath = PathLength;
   }
 }
 break if !defined FoundObject;
 Distance++;
} while (Distance < ShortestPath); // If we had object closer than a distance we need to check -- terminate

return FoundObject;


Logged
he greatest programming project of all took six days; on the seventh day the programmer rested. We''ve been trying to debug the *&^%$#@ thing ever since. Moral: design before you implement.
Pages: 1 [2]