Bay 12 Games Forum

Please login or register.

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

Author Topic: Multhreading Dwarf fortress  (Read 13450 times)

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Multhreading Dwarf fortress
« Reply #45 on: March 30, 2011, 09:30:53 pm »

Oh, that's when it falls/is moved, not where it actually goes being part of the pattern.  I think where water actually flows is still random if it isn't falling.  If you can count out a ten-to-one ratio of falling to not falling per frame, then I guess the pattern is just based on making every 11th tile get checked for moving per frame.

As I said before, though, if water is "non-flowing", the checks are less frequent, which is why you can often see your miner get several tiles out of the way before the water or magma starts to pour in on the tiles he was occupying when he "broke the dam" by mining through the wall holding the magma back.
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

zncon

  • Escaped Lunatic
    • View Profile
Re: Multhreading Dwarf fortress
« Reply #46 on: March 30, 2011, 10:03:51 pm »

Okay, here's a question for those here more knowledgeable about path-finding then myself.
How is it that we run into this issue with DF as early as 80-100 moving dwarfs/animals/invaders but nearly any RTS can easily have 500+ units all moving/attacking and whatnot with out any slowdown?

On another note, I would love to see a version of DF able to run processes via a graphics card processor(s). I've read claims that CUDA can outperform a standard processor by 8-10x for simple calculations.
Logged

profit

  • Bay Watcher
  • Finely Crafted Engravings... Or it didn't happen.
    • View Profile
Re: Multhreading Dwarf fortress
« Reply #47 on: March 30, 2011, 10:42:10 pm »

Okay, here's a question for those here more knowledgeable about path-finding then myself.
How is it that we run into this issue with DF as early as 80-100 moving dwarfs/animals/invaders but nearly any RTS can easily have 500+ units all moving/attacking and whatnot with out any slowdown?

On another note, I would love to see a version of DF able to run processes via a graphics card processor(s). I've read claims that CUDA can outperform a standard processor by 8-10x for simple calculations.

Why say 500... I have seen programs 10 years old that had multiple thousands with little slowdown. (Darwinia)

I have a sneaky suspicion though that they use massively simplified pathfinding and job finding.  Also dwarf fortress really does not track 100 dwarves, it tracks 100 dwarves, 100,000 stones, 3000 flutes, 5000 body parts 5,000,000 contaminants, 2,000,000 separate temperatures, 56,000 fluid tiles....

On the same token... yeah the performance is kinda pitiful and speed is the number one annoyance of dwarf fortress....  It pisses me  off a lot... And makes me grind my teeth when FPS:0 appears.   I think there is room for massive optimization.
  I still do think a smart multithreading solution is a good idea though.  To be honest, I am amazed how well toady has done with the program,  I use multithreading solutions in much simpler programs to keep things responsive, to have this as a single thread and still be semi playable is pretty good.   Although the interface not being in a separate thread annoys the piss out of me when the fps falls and I try to move around the map without pausing... it is like working with molasses.

PS. CUDA processing works really well for some things, not so good for others... I am betting this would be one of those "Others"   But I have never delved into it because nothing I have ever done would significantly benefit from faster processing besides shaving a second off a few seconds of calculation time that humans then need a few minutes to handle anyhow.
« Last Edit: March 30, 2011, 10:48:23 pm by profit »
Logged
Mods and the best utilities for dwarf fortress
Community Mods and utilities thread.

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Multhreading Dwarf fortress
« Reply #48 on: March 30, 2011, 11:36:45 pm »

Darwinia isn't 10 years old, it's from 2005.

Anyway, to answer the major question about "why are other games faster at pathfinding", there are several reasons.

First, Darwinia and other games like that make for fairly easy pathfinding since they have mostly large open areas with nothing to pathfind around.  Just look at what happens when you try to tell Darwinians to go to a point where they have to go around a bend to avoid the water - they walk straight up to the water, then get confused.  That isn't pathfinding, that's just going in a straight line.

Second, most games "cheat" at pathfinding.  They don't generate their own pathfinding maps, they rely upon a designer-created set of waypoints which, in turn, relies upon the fact that maps are mostly static.  You can especially see this in various "cover shooter" games, where every piece of cover or wall has to be "painted" with the parts of the map you can crouch behind, while other pieces of wall refuse to allow you to hide behind them.  AI units will walk from one hand-painted waypoint to another along the predefined routes they have to access various parts of the map. 

Third, most games use some tricks to hide the time it takes them to pathfind.  Often, they'll only allow one unit to pathfind per frame, and all the other units will stand and idle until they get a turn - this prevents a large number of pathfinding units from causing notable spikes in lag, but involves making several units that are commanded simultaniously to move just burn some turns. 

Finally (and this is somewhat related to the first), pathfinding isn't as good as it really should be in many games... See the video here - http://www.ai-blog.net/archives/000152.html  (That was linked by Mohican in the most recent pathfinding thread.) (That article also covers things like waypoint pathfinding and talks about why it's time to get rid of it, too...)

The thing is, most of the crutches and cheats that other games rely upon don't work in DF.

The other thing is, basically, Toady knows A* alone isn't as efficient as some of the algorithms that are in the suggestions threads, but he's been hesitant to impliment them.  (He also wants to conserve on memory consumption and the algorithm has to react to dynamically changing map statuses.) We've been arguing about how to make an ideal system, but a hierarchical system of almost any sort would make pathfinding run potentially one or two orders of magnitude faster in virtually every common situation, (and no worse than standard A* in the worst cases,) and also allow for multiple forms of locomotion, such as having fliers or swimmers or multi-tile vehicles becoming able to pathfind properly.

Basically, there's a reason why people have been saying that rewriting pathfinding would be easier and far more fruitful a way to speed up the game than multithreading.  Multithreading would MAYBE produce a doubling of speed in return for months of programming and probably a year of lingering bugs, but pathfinding rewrites would make the game run ten times as fast for a fraction of the time spent rewriting the code.
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

profit

  • Bay Watcher
  • Finely Crafted Engravings... Or it didn't happen.
    • View Profile
Re: Multhreading Dwarf fortress
« Reply #49 on: March 30, 2011, 11:59:53 pm »

If I can see 100 FPS with 200 dwarves i will be happy even if it is only using one core....

Right now my forts grind to a halt once I branch out into multi-Z levels....  Of course if dwarves are just around the embark wagon, 224 of them can be there and I can get lots of FPS...   Once I start digging the frames start dropping....
Logged
Mods and the best utilities for dwarf fortress
Community Mods and utilities thread.
Pages: 1 2 3 [4]