Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Stockpiling Stone Behaviour  (Read 488 times)

Blackcat

  • Bay Watcher
    • View Profile
Stockpiling Stone Behaviour
« on: September 06, 2006, 04:16:00 am »

Some background: In my last fortress, I worked on the plan of digging 3-wide corridors, with rooms allocated in 27x27 blocks. Overall, a plan that worked well, but due to the small distance between the river and the chasm, I could only fit one block in, with smaller rooms either side.

Now, as I dug out the corridors and the 27x27 areas, I allocated the corridors as stone storage. Of course, as the fortress got bigger, I ended up with more stone stockpiles. I continued the plan past the chasm, as the big room areas would be ideal for workshops and storage, laying down stone stockpiles as I went.

Problem 1:
I hit what appeared to be a 'critical mass'. Every three seconds or so, the game would pause, obviously processing something, for about a second. Task Manager showed a usual CPU usage of about 35%, with these pauses corresponding to a 100% usage. I began immediately to switch off various tasks going on to identify the problem.

In the end, it turned out to be the stone stockpiles. I stumbled across it when I unallocated a stockpile in a room area that I wanted to move cloth workshops and stockpiles into. Immediately after unallocating it, although it caused a massive amount of hauling jobs, the slowdowns/pauses disappeared.

In the end, I went around and unallocated every stone stockpile, thinking to hell with being neat.

Problem 2:

After building a bunch of catapults, I needed to get a lot of rock to them so that some peasants set to Siege Operating and nothing else had ammo. So, I created a stone stockpile next to them.

Instead of walking a screen or two east to grab stone (the corridors still had lots of stone in them), all the dwarves proceeded right over to the far east over the chasm, where I was in the process of mining for ore. And as I watched, I saw that the dwarves would stockpile the 'newest' stone. Not the nearest to the stockpile, or the nearest to them when they decide to haul, but the stone that had just been dug.

As a test, I unallocated my massive (and only) ore stockpile, and then dug some more ore out. I then created a new ore stockpile right where the old one was, but covering the empty space that didn't have ore on. And again, the dwarves would haul the 'newest' ore.

Logged

lipasto

  • Escaped Lunatic
    • View Profile
Re: Stockpiling Stone Behaviour
« Reply #1 on: September 06, 2006, 07:03:00 am »

Seems to be happening to me too. I think turning off the stone hauling stops the 'lagging' or at least lessens it.
Logged

Maurog

  • Bay Watcher
    • View Profile
Re: Stockpiling Stone Behaviour
« Reply #2 on: September 06, 2006, 07:22:00 am »

Out of curiosity, what *do* dwarves use for pathfinding? Is it plain old Dijkstra algorithm or something more complicated?
Logged

Blackcat

  • Bay Watcher
    • View Profile
Re: Stockpiling Stone Behaviour
« Reply #3 on: September 06, 2006, 07:51:00 am »

Another strange piece of information about stockpiles...

It would appear that when an item is set to be stockpiled (either when the job is issued, or when the item is picked up), it will be placed on the nearest available stockpile spot.

So what's the problem? Well, "nearest" here actually means "absolute nearest, ignoring any and all obstacles."

Simple example: You dig two 3-wide corridors side by side, joined at the ends. The first is set to be a stone stockpile. When a rock is picked up from the mid-way point of the second corridor, the dwarf will quite happily haul it to one end of the corridor, then back along the other to deposit the stone in the empty spot that was nearest to where the stone originally lay.

Logged

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: Stockpiling Stone Behaviour
« Reply #4 on: September 07, 2006, 10:31:00 pm »

It's hard to say what's going without knowing more about how many stone piles there were and how much stone there was.

Right now, the stone checks for places to be stored.  If a far stone snags a spot before a near stone, then that's it.  The new stones probably get to check first.  They also snag the "closest" spot, without doing an expensive path-find.  Now, if a dwarf actually picks the stone up, it could do a more proper check, but if the other spots have been reserved by other stones in the mean-time, that wouldn't work.  Of course there are ways to fix this, but there are many issues to consider before committing to any changes.

Logged
The Toad, a Natural Resource:  Preserve yours today!

tourettedog

  • Bay Watcher
    • View Profile
Re: Stockpiling Stone Behaviour
« Reply #5 on: September 08, 2006, 02:58:00 pm »

I get horrendous slow-down when I have non-square stockpiles, or ones interrupted by lots of unmined pillars and suchlike.

I reached the point where I pretty much decided to hollow out the mountain, and started dropping stockpiles in the incomplete excavations, giving them really irregular shapes, and the game became almost unplayable as long as I had stone hauling turned on.  Replacing the stockpiles with unbroken square ones helped a lot.

Logged

Blackcat

  • Bay Watcher
    • View Profile
Re: Stockpiling Stone Behaviour
« Reply #6 on: September 08, 2006, 03:22:00 pm »

Toady:

Concerning the behaviour of which stones get stored where, that's probably something that can be glossed over for now. Many-to-many pathfinding and distance optimising is a complete bitch to compute, so the way it currently works will do just fine.

As for the slowdowns, I was surprised at the difference unallocating one stone stockpile had. With the stockpile present, it was evidently doing some major crunching in the engine. But deleting just that one stockpile completely cleared the condition. It was a 27x3, one of over 30 such piles.

Logged