Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: "Nearby materials" ignores pathfinding  (Read 530 times)

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
"Nearby materials" ignores pathfinding
« on: October 30, 2007, 02:18:00 am »

Okay...It wasn't so bad in the old version when your mason decides, "The closest stone is on the other side of the wall!"  He takes the long way around to get the stone that is, technically, the closest.

I don't know if masons still do that... But the "Pick a material to build this object" screen does.  My fortress has some elaborate corridors going down several levels with some badly designed switchbacks, and there's a corridor that goes UNDER the road I want to build.

So when I chose materials for my road...the first ones it selected were the ones straight down from the road site.  Coincidentally, they were also the FURTHEST materials that it could possibly have chosen.  My mason walks forever, past much closer stones of the same type, to get there.

I figured that the new screen would use actual pathfinding to pick materials.  Yeah, it's a performance hit, but it's not too bad since you only do it ONCE for each possible construction object when you create a building.  And you don't create that many buildings...and a little lag on that screen is acceptable.

Yeah, right now it's taking about an extra realtime half hour to create this road because of the pathfinding.

Logged
Some things were made for one thing, for me / that one thing is the sea~
His servers are going to be powered by goat blood and moonlight.
Oh, a biomass/24 hour solar facility. How green!

Veroule

  • Bay Watcher
    • View Profile
Re: "Nearby materials" ignores pathfinding
« Reply #1 on: October 30, 2007, 03:27:00 am »

Another note with that screen is that it takes much longer to display based on the size of the region chosen during embarkation.  This might just be an issue with my system not having enough ram to do it quickly, or it might be an issue with how items are stored.
Logged
"Please, spare us additional torture; and just euthanise yourselves."
Delivered by Tim Curry of Clue as a parody of the lead ass from American Idol in the show Psych.

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: "Nearby materials" ignores pathfinding
« Reply #2 on: October 30, 2007, 08:30:00 pm »

It's expensive to do the connectivity calcs for the items, based on the size of the map, and it has to worry about things like which side of the building it is on and so forth.  That said, something seems to be up with the corridor running underneath then.  Maybe it isn't checking for floors properly.
Logged
The Toad, a Natural Resource:  Preserve yours today!

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
Re: "Nearby materials" ignores pathfinding
« Reply #3 on: October 30, 2007, 08:55:00 pm »

All materials were on a different floor from the structure being built (since it was a road and I was digging underground).

The closest stones by pathfinding were, oh, 30 tiles away horizontally and down one level, but it was a nice straight walk.

The stones that got picked were about 0-4 tiles away horizontally and down four levels, but like I mentioned, HUGE switchbacks.  It was a long and arduous walk.  It was like being on the other side of the river, repeatedly.

I know it's computationally expensive, but I can think of a few potential improvements.  For one thing...So there's 99 limestone stones lying around and your road needs eight of them.  Okay.  So start at the middle of your building (very short range inaccuracies may not be important, except for bridges), and search outwards from there.  Keep going until you run into your first eight pieces of limestone, and then STOP.  All limestone is the same and there's really no reason to choose which limestone to use, anyway.  You only have to pathfind for whatever material the user has highlighted--you can abandon the data for any material they move off of, as long as changing the highlight stays snappy.  Maybe for building doors and stuff where quality matters, you can figure out the closest ten right away, and only continue if the player actually expands that view.  Just remember that when the user is pawing through a menu, you can take advantage of their slow reaction time and crunch numbers!

It might really suck if your limestone is across the map, down three levels, around a corner, over the bridge, through the maze, and up the tower.  Maybe have a cutoff after a certain amount of time spent, and give up.  But for me as a player, it is extremely important to my play experience (heh) that my dwarves know how to pick some reasonably close ingredients.  I think that waiting a second for computation time is better than waiting half an hour because my dwarves didn't plan very well.

Meh.  This is just my favorite feature to improve.  I absolutely LOVE the new simplified interface, and in a 2d world it would be perfect--but in 3d, it might actually perform worse than the old interface unless pathfinding (or a good heuristic!) goes in.

If it's just the delay to the player that you're worried about, I think it would make a great init variable:  Number of milliseconds to spend pathing on ingredient selection.  You could divide it by "ms to spend when a mason is doing his own thing at a workshop" (a low number) and "ms to spend when the player is placing a building (a high number).  You could have a little spinning bar on the build window that tells you it's still pathfinding, and let the player decide how long to wait.  You could have a button that says "Do the math right now, for these ingredients".  I just feel reeeally strongly about being able to trigger pathfinding on ingredients.  It makes the difference between an attentive and responsive architect, and an architect that you want to punch in the face.  I don't like to hate my dwarves.

Logged
Some things were made for one thing, for me / that one thing is the sea~
His servers are going to be powered by goat blood and moonlight.
Oh, a biomass/24 hour solar facility. How green!

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: "Nearby materials" ignores pathfinding
« Reply #4 on: October 31, 2007, 09:25:00 pm »

Sowelu, that spread out is what it does, which is why it can report the distance.  There just seems to be a few bugs with how it is doing that that I have to work out.  It's also why you get some lags moving your placement around on large maps -- because the flood that it is doing is expensive.
Logged
The Toad, a Natural Resource:  Preserve yours today!