Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 31 32 [33] 34 35 ... 43

Author Topic: Anouncing The PathFinder Project  (Read 98120 times)

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: Anouncing The PathFinder Project
« Reply #480 on: January 12, 2010, 08:09:43 am »

actually, there is a barrier for data structures where increasing their size will reduce performance. Once a data structure can no longer fit in available cache space, it takes hundreds of cpu cycles to retrieve it from main memory. Its called cache thrashing, and its probably the biggest reason why AMD chips are less powerful than Intel, they just have smaller cache.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Starver

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #481 on: January 12, 2010, 10:07:27 am »

actually, there is a barrier for data structures where increasing their size will reduce performance. Once a data structure can no longer fit in available cache space, it takes hundreds of cpu cycles to retrieve it from main memory. Its called cache thrashing, and its probably the biggest reason why AMD chips are less powerful than Intel, they just have smaller cache.
a) A number of AMDs have less cache than a number of Intels, more like.  Unless Intel's chucked all the budget/low-cache systems recently and AMD hasn't bothered with top-end variants, but I haven't cared to check the current situation in detail recently, so I could be wrong and my real comment is:
b) The time taken to transfer data (raw data[1] blocks, not data structures) is limited by bandwidth to the processor, which is narrower than the cache may be small on all systems I've worked with where there is a cache that's anything more than just a bus-width register.

But I am a bit out-of-date with modern architectures and methodologies, so I suppose someone could have developed an efficient sub-caching system on a system with an ultra-wide and/or ultra-fast pipeline into it, or even manage to do a L2/L1 staging system for data (and sub-set of data) of differing priorities.  And of course taking into account multi-core requirements where applicable.


Personally, based upon older phenomena such as "Pagefile Thrashing" and similar (except, I suppose, in reverse), I would have used the term "Cache Thrashing" to indicate that, having loaded one or more complete sets of data into the cache the computations then indicate that another bit of data is required, displacing data that (unbeknownst to the cachig algorithm) is subsequentally to be called back upon by the new data, which displaces another cache item but (once back) facilitates computations that ask for that old item, etc.  Thus shoving whole pages (or cache-level equivalent) of data in and out of the quick-but-small storage area (cache for memory, memory for pagefile) taking more time to access than it might have been if it was just a matter of reading the large-but-slow memory in-situ in the first place.


Well, those are my thoughts, for what it's worth.  Probably worth nowt. :)

[1] As the processor won't have any idea it what groupings it should cache, unless you've programmed at Assembler level and deliberately worked within MMX-style arrayed data references (or whatever they use these days), or have a very good compiler that can manage to optimise that for you despite your being unaware of what's required.  If you have a structure containing a rapidly changing/accessed flag/connectivity byte[2] next to a fairly static array[3] only occasionally queried, then does the cache (and data pipeline bringing it to the chip for caching) shove a block area of memory across or pick and choose bits and pieces (e.g. just the flag bytes) from a number of different cachable areas?  Depending on the microcode, assembler and whatnot, it could go either way, but my hunch is that a blocks would be cached just for the sake of their flag-bytes, in this kind of circumstance.  Less extreme variants possible, but with the same idea.

[2] Maybe saying "If trying to walk through here, you can go from $adjacent_area1 to $adjacent_area2 in $steps_for_1to2 cycles" in a DF context, and used to determine if it's worth pathing through that area.

[3] The internal routing details of a DF 'zone' which, due to it being not the most promising route and rejected as a possible path, isn't actually explicitly queried to find how to pass from Adjacent Area 1 to Adjacent Area 2 through this.
Logged

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Anouncing The PathFinder Project
« Reply #482 on: January 12, 2010, 08:39:28 pm »

The memory required can be reduced by abstracting pure sky layers (If anything altered the path cost, it wouldn't be pure sky anymore, so using memory for it would just be a waste) and fully solid layers(undiscovered and solid rock), possibly splitting it to an array pointer per Z-level, each optionally null with some other information clasifying why, possibly also have it split by world tiles, so a 6x6x(20+15sky+15underground) would have 15x6x6 abstracted to sky, 15x6x6 abstracted to undiscovered (Unless it has creature pathing, and it likely will in the next version), and anywhere from 0 to 6x6x20 world-map-z-layers abstracted to fully stone.  In fact, using the world map squares as the main pathing grid could greatly speed up pathing if each one is simply treated as pathable/unpathable and what neighbors are connected. It couldn't replace the tile paths themselves, but it could be used to path a more accurate assumption of the remaining distance when A* can factor the mountain in the way into it's optimistic calculation and ignore some less viable paths.

A better method probably exists, but being able to ignore unpathable and empty tile blocks would save on memory and provide a useful abstraction layer for other improvements.
Logged
Eh?
Eh!

peterix

  • Bay Watcher
    • View Profile
    • Dethware
Re: Anouncing The PathFinder Project
« Reply #483 on: January 12, 2010, 09:11:58 pm »

That's what DF does. it doesn't store solid rock and empty map blocks (16x16x1 tile areas). They have to be vertically contiguous though.

Impaler[WrG]

  • Bay Watcher
  • Khazad Project Leader
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #484 on: January 12, 2010, 11:34:06 pm »

I'm doing the same thing in Khazad and the Pathfinder, but without the contiguous requirement.
Logged
Khazad the Isometric Fortress Engine
Extract forts from DF, load and save them to file and view them in full 3D

Khazad Home Thread
Khazad v0.0.5 Download

Djohaal

  • Bay Watcher
  • [PREFSTRING:Utter Insanitiy]
    • View Profile
    • My deviantart
Re: Anouncing The PathFinder Project
« Reply #485 on: January 14, 2010, 01:05:48 pm »

Well, unless we are to do some assumptions on the simulation, cutting down on the pathfinding nodes will not be simple. From what I understand, DF currently manages pathfinding via a rather "brute force" system. We should think on ways to optimize that.

First thing that comes to my mind is that in large, uniform open floors (like tower cap farms and such), a quadtree subdivision could speed up the pathfinding a lot. Perhaps it could lead the dorfs to the nearest point on the quad subdivision, then from there on the "real" pathfinding system would start.

Now for the fortress itself, an interesting idea would be for the software to analyze and interpret the pathing in archtectural terms in order to optimize it.
Most fortress designs have corridors, rooms and such. If an analyzer was to interpret and abstract them into simplified elements (say, a "corridor" with 20 doors, instead of a 60-tile long node cloud with branching units that would be the rooms) it could speed up the pathfinding. For instance, if Urist McLost was to go to his bedroom, the pathfinder would trace the path across a pre-analyzed and already laid out corridor system to his bedroom's door. Once he made it there, the "brute force" system would path him to his bed, closet, throne, etc.

Doors and DF room definitions could help the analyzer to lay out its corridor/room tree. A significant "pathing mutation" would have to be implemented though, to avoid the corridor system squeezing all your dwarves in a single lane on that 5-wide hall you did though. Another issue I can foresee is dealing with rooms in corridors. (I for instance tend to make lateral expansions to my corridors to make my dining halls) and doors in the corridors themselves.

The main issue is that constantly analyzing the fortress's layout to draw and redraw the corridor tree would require so much processor power. Perhaps there could be settings on it so it'd auto-update the corridor tree after a certain number of new tiles were dug out. A secondary system  that looked up significant changes in areas that are "already mapped" on the corridor tree could also avoid unecessary processing.

Last but not least though, this analyzer/simplificator system could be coded on such a contained way that it could be threaded independently of the main pathfinder. This would greatly enhance performance if we focus on paralelism.
Logged
I really want that one as a "when". I want "grubs", and "virgin woman" to turn into a dragon. and monkey children to suddenly sprout wings. And I want the Dwarven Mutant Academy to only gain their powers upon reaching puberty. I also have a whole host of odd creatures that only make sense if I divide them into children and adults.

Also, tadpoles.

PencilinHand

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #486 on: January 14, 2010, 04:26:24 pm »

stuff

I understand 30+ pages is a long read so I will simply tell you that all of this has already been discussed, most of it at quite some length.  Virtually all of it has been discarded as it would involve so much pre-processing as to be a fools errand and beyond the scope and of intend for the project.  The only one that I feel has any potential usefulness in the near future is the implementation of parallelism on a per path level(should help minimize the headaches).  However, parallelism has been "set aside" as overly ambitious for a first go, which this is.

Part of the point of this project is to be able to present a superior, "simple" to integrate pathfinder, for Toady to adopt if he so chooses.  Offering a pathfinder that requires extensive rewriting every time Toady wants to change something is NOT an option he will take.
Logged

numerobis

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #487 on: January 14, 2010, 10:43:02 pm »

I'm not so sure the concept of having an overlay has been discarded.  That's kind of the entire point here.  It's not clear that quadtrees are the way to go for the hierarchical structure: a twisty windy path with only one entrance and exit would be a lot of nodes in a quadtree, but might conceivably be contracted to a single node using some other partitioning of space.

Parallelism has indeed been discarded twenty times over, because it's unlikely to be helpful compared to just working hard on the sequential code.
Logged

PencilinHand

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #488 on: January 15, 2010, 01:03:01 am »

I'm not so sure the concept of having an overlay has been discarded.  That's kind of the entire point here.  It's not clear that quadtrees are the way to go for the hierarchical structure: a twisty windy path with only one entrance and exit would be a lot of nodes in a quadtree, but might conceivably be contracted to a single node using some other partitioning of space.
There have been many discussions about different partitioning systems but the biggest problem is the lack of a convenient way for those interested to implement and compare them.  Last I head this was being worked on.

Parallelism has indeed been discarded twenty times over, because it's unlikely to be helpful compared to just working hard on the sequential code.
Yes and no.  Good sequential code will always be useful.  Parallelism is also useful to a point.  Somethings would work well parallel and some wouldn't.  Map preprocessing could probably be made parallel, and reprocessing after a map change may also be doable.  Each path if individually treated as a thread might be a workable means of implementing a parallel method with minimal collusion and overhead.  However, I am not doing the coding so I can not be sure of the details.  Besides those who are doing the coding have said they aren't going to do anything parallel, at least for now.
Logged

ggeezz

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #489 on: February 10, 2010, 02:37:55 pm »

Is this still being worked on?

Just wondering.  I found it rather fascinating, if a bit over my head.
Logged

eternal

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #490 on: February 19, 2010, 05:38:11 pm »

Is this still being worked on?

Just wondering.  I found it rather fascinating, if a bit over my head.

I'm also interested and bumping this.  Going to read through the whole thread, but I'm wondering what the status of the project is.  Real life definitely takes a toll on these things :-[
Logged

Sagabal

  • Bay Watcher
  • Komrade!
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #491 on: February 28, 2010, 11:36:32 am »

I'm also interested and bumping this.  Going to read through the whole thread, but I'm wondering what the status of the project is.  Real life definitely takes a toll on these things :-[

Bumping again.  Has any progress been made?  I'd like to see this happen.
Logged

Impaler[WrG]

  • Bay Watcher
  • Khazad Project Leader
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #492 on: February 28, 2010, 02:38:52 pm »

Sorry for the lack of updates, I've received a request for an update and though it best to post here so everyone can see.

As of right now Pathfinding is on hold as I turned back to the Graphics engine in Khazad which I've decided to re-build in Ogre.  The work done so far has been good but I've failed to attract a dedicated developer who would continue building it in my absence.  Splitting the code into it's own sourceforge project was predicated on having that dedicated developer though as it is right now the code very ready to cleave off as I've followed the kind of encapsulation that allowed the same to be done with DFHack.  If anyone is interested in working on picking up the project just PM me and I can get you access the SVN repository.
Logged
Khazad the Isometric Fortress Engine
Extract forts from DF, load and save them to file and view them in full 3D

Khazad Home Thread
Khazad v0.0.5 Download

deek0146

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #493 on: March 01, 2010, 04:22:26 am »

I would definately be interested in taking a look at that can i get the repository address? Emm message this account or my hotmail is deacon15@hotmail.co.uk
« Last Edit: March 01, 2010, 04:28:46 am by deek0146 »
Logged

ArPharazon

  • Bay Watcher
    • View Profile
Re: Anouncing The PathFinder Project
« Reply #494 on: March 05, 2010, 01:56:01 pm »

I apologize for not having read the thread, but has anyone tried something like ant trails, at least for civilian dwarfs?
Logged
Pages: 1 ... 31 32 [33] 34 35 ... 43