Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 4 5 [6]

Author Topic: Just a little bit of cpu optimization? pretty please?  (Read 9593 times)

Draco18s

  • Bay Watcher
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #75 on: December 21, 2008, 12:17:57 am »

but then, it's been frequently complained upon that pathfinding to items doesn't take z-levels and stairs into account, so it really is 2D in DF

Wrong.  I takes stairs/ramps into account all the time.  Haven't you ever watched dwarves go over a hill rather than around?

What it doesn't do is take THE ENTIRE Z AXIS into account when CALCULATING DISTANCES BETWEEN OBJECTS.

Is rock A closer to me than rock B?  Rock A at is X+4, Y-1, Z+30.  Rock B is X+10, Y+5, Z+0.  Rock A must be closer, it's only 4.1 tiles away!
Logged

Footkerchief

  • Bay Watcher
  • The Juffo-Wup is strong in this place.
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #76 on: December 21, 2008, 12:20:31 am »

^^^ Bingo.  Has there ever actually been a thread about that issue?  It seems like such a small and easily fixed thing, so maybe he just doesn't know about it.
Logged

texmith

  • Bay Watcher
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #77 on: December 21, 2008, 06:00:19 am »

Ponder the possibilities:

Urist needs a rock. There's 500000 rocks lying around, so he does a quick dx+dy+dz test on each to find out which is closest. Rock a is the closest, he can get to it, so he calls the pathfinding routine, finds the best path and goes to get it.

Urist needs a rock. There 's 500000 rocks lying around so he calls the pathfinding routine for each rock to find the closest... the cpu melts and Urist is drowned in lava.
Logged

Silverionmox

  • Bay Watcher
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #78 on: December 21, 2008, 09:10:51 am »

Alternatively, there could be a floodfill from the place of the dwarf, and the first item encountered that fits the requirements is taken.

Or there could be a bias for the x,y plane when searching for items, since dwarves can more easily move on that one than the z-axis.
Logged
Dwarf Fortress cured my savescumming.

Granite26

  • Bay Watcher
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #79 on: December 21, 2008, 02:31:00 pm »

Alternatively, there could be a floodfill from the place of the dwarf, and the first item encountered that fits the requirements is taken.
Win!
Or there could be a bias for the x,y plane when searching for items, since dwarves can more easily move on that one than the z-axis.
Lose! (Special case based on how you et al build your fort.)

Silverionmox

  • Bay Watcher
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #80 on: December 21, 2008, 04:43:11 pm »

I know, the first one would work more reliably. The second is more of a quick and dirty fix, even though items can only lie on a mined out surface if it's facing up.
Logged
Dwarf Fortress cured my savescumming.

Align

  • Bay Watcher
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #81 on: December 21, 2008, 05:28:16 pm »

There must be a reason floodfill isn't already used.
Logged
My stray dogs often chase fire imps back into the magma pipe and then continue fighting while burning and drowning in the lava. Truly their loyalty knows no bounds, but perhaps it should.

Silverionmox

  • Bay Watcher
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #82 on: December 21, 2008, 05:33:28 pm »

There must be a reason floodfill isn't already used.
It potentially needs to flood almost the whole map. I don't know whether that would cause a major, minor or no lag, ...  sometimes or most of the time.. Most likely it's just a quirk inherited from 2d, waiting to be cleaned up.
Logged
Dwarf Fortress cured my savescumming.

Random832

  • Bay Watcher
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #83 on: December 21, 2008, 10:14:11 pm »

There must be a reason floodfill isn't already used.
It potentially needs to flood almost the whole map. I don't know whether that would cause a major, minor or no lag, ...  sometimes or most of the time.. Most likely it's just a quirk inherited from 2d, waiting to be cleaned up.

Flood fill is also not guaranteed to reach near tiles before far tiles. Note that the animation at http://en.wikipedia.org/wiki/Flood_fill reaches the far lower left corner before it hits any of the other adjacent cells.
Logged

Silverionmox

  • Bay Watcher
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #84 on: December 22, 2008, 04:56:57 am »

There must be a reason floodfill isn't already used.
It potentially needs to flood almost the whole map. I don't know whether that would cause a major, minor or no lag, ...  sometimes or most of the time.. Most likely it's just a quirk inherited from 2d, waiting to be cleaned up.
Flood fill is also not guaranteed to reach near tiles before far tiles. Note that the animation at http://en.wikipedia.org/wiki/Flood_fill reaches the far lower left corner before it hits any of the other adjacent cells.
I had this kind of flood fill in mind:
http://en.wikipedia.org/wiki/File:Wfm_floodfill_animation_queue.gif
Logged
Dwarf Fortress cured my savescumming.

Footkerchief

  • Bay Watcher
  • The Juffo-Wup is strong in this place.
    • View Profile
Logged

Mikademus

  • Bay Watcher
  • Pirate ninja dwarves for great justice
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #86 on: December 22, 2008, 03:43:50 pm »

That algorithm has moved from simple flood filling into basic ray casting...
Logged
You are a pirate!

Quote from: Silverionmox
Quote from: bjlong
If I wanted to recreate the world of one of my favorite stories, I should be able to specify that there is a civilization called Groan, ruled by Earls from a castle called Gormanghast.
You won't have trouble supplying the Countess with cats, or producing the annual idols to be offerred to the castle. Every fortress is a pale reflection of Ghormenghast..

Andir

  • Bay Watcher
    • View Profile
Re: Just a little bit of cpu optimization? pretty please?
« Reply #87 on: December 22, 2008, 07:10:17 pm »

That algorithm has moved from simple flood filling into basic ray casting...
More than one way to skin a cat.
Logged
"Having faith" that the bridge will not fall, implies that the bridge itself isn't that trustworthy. It's not that different from "I pray that the bridge will hold my weight."
Pages: 1 ... 4 5 [6]