Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: player-supported path-finding optimization  (Read 1034 times)

nondescuid

  • Bay Watcher
    • View Profile
player-supported path-finding optimization
« on: April 14, 2008, 10:00:00 am »

From what I understand, the pathfinding that 200 dwarves have to do accounts for a lot of the performace hit one gets in large forts.

Suggestion: Let the player define routes for the dwarves to take from a point A to a point B. These would work as some kind of 'highways': dwarves who have to travel a longer distance will get to the nearest highway, from there to the point on the 'highway net' which is nearest to their destination, then to their destination.

This is kinda the same way modern car navigation systems work - if you are travelling a long distance, they first get on a highway, so all the other ways from A to B using lots of small roads do not have to be considered.

I don't know if this would work - it might not save much performance if often used routes are already cached or something, but I think this might be a way to combat the FPS hit which occurs in huge forts.

Of course, enemies (and maybe squads on duty) will ignore these, always taking the shortest way possible.

Logged

Fieari

  • Bay Watcher
    • View Profile
Re: player-supported path-finding optimization
« Reply #1 on: April 14, 2008, 11:15:00 am »

This is sortof already in.  You can designate low, mid, and high traffic areas.
Logged

FlexibleDogma

  • Bay Watcher
  • xGiant Cave Spider Silk Sockx Merchant
    • View Profile
Re: player-supported path-finding optimization
« Reply #2 on: April 14, 2008, 01:29:00 pm »

Related things I'd love to see:

Tightly closed doors/forbidden doors treated as walls by path finding.  (Prevents pets from sitting a door trying it over and over again if it's tightly closed).

Always build on square with lowest traffic cost.  This would prevent dwarves from building walls/floodgates/etc that pin them in, assuming you assigned the proper traffic designations.

Logged

Silverionmox

  • Bay Watcher
    • View Profile
Re: player-supported path-finding optimization
« Reply #3 on: April 14, 2008, 01:37:00 pm »

quote:
Originally posted by Fieari:
<STRONG>This is sortof already in.  You can designate low, mid, and high traffic areas.</STRONG>

Yes,  but I wonder: does it decrease the need for calculation or is it just the same pathfinding algorithm with differen numbers?

Logged
Dwarf Fortress cured my savescumming.

Mikademus

  • Bay Watcher
  • Pirate ninja dwarves for great justice
    • View Profile
Re: player-supported path-finding optimization
« Reply #4 on: April 14, 2008, 01:45:00 pm »

To the OP:

Basically, rather than putting the onus on the player, mature large-scale systems use multi-tiered pathfinding. My guess that pathing takes so much CPU time in DF is because the game only generates and updates one fine-meshed node-map for the entire fortress (or per Z-level). If so, this aspect could be optimised between ten and a thousand times depending on current implementation and design restrictions.

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..

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
Re: player-supported path-finding optimization
« Reply #5 on: April 14, 2008, 08:18:00 pm »

quote:
Originally posted by Silverionmox:
<STRONG>
Yes,  but I wonder: does it decrease the need for calculation or is it just the same pathfinding algorithm with differen numbers?</STRONG>

Yes, it does decrease the need for calculation--due to the way the algorithm works.  People have noted, for example, that if you mark the only entrance to a small cave "Restricted", and someone wants to pick up a sock from the cave, it will try to search the rest of the map for a better way and slow the game down.  OTOH, if you mark a highway "High Traffic", then it will search along the highway first--and often won't do as much searching anywhere else, if the highway gets where the dwarf wants to go.

However all animals and hostiles ignore your designations, and they are often the biggest source of pathfinding problems.

To summarize:  Good use of high-traffic can speed up your dwarves' pathfinding.  Bad use of low-traffic/restricted can slow down their pathfinding.  It's possible to speed up pathfinding using restricted areas but only if you use them VERY VERY WELL.  But it probably won't matter because ambushers will always be slow anyway.

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!

numerobis

  • Bay Watcher
    • View Profile
Re: player-supported path-finding optimization
« Reply #6 on: April 15, 2008, 02:04:00 pm »

quote:
Originally posted by Mikademus:
<STRONG>To the OP:

Basically, rather than putting the onus on the player, mature large-scale systems use multi-tiered pathfinding.</STRONG>


Sadly, our fortresses aren't mature.  There are a lot of changes that happen pretty often.  Supporting that with a dynamic search structure is a bit tricky, which is, according to the gamasutra interview, part of the reason that Toady has opted for a slower but less bug-prone strategy of searching from scratch every time (except for the connected components stuff, which you will note has indeed spawned a couple bugs).

Logged