Bay 12 Games Forum

Please login or register.

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

Author Topic: Spin the pathfinding off to other threads.  (Read 6992 times)

aha

  • Bay Watcher
    • View Profile
Spin the pathfinding off to other threads.
« on: June 26, 2012, 03:34:42 pm »

Spin the pathfinding off to other threads. Processor speeds have stopped rising - the future is more cores. I have DF at 13-14 FPS, but only 17% of available CPU processing is used:(
Don't even need to modify the main game much. Wrap it into launcher that starts the main executable and a pool of pathfinding threads that have access to shared memory holding the map. As something needs a path it is put into the queue in the main game, launcher is polling the queue and will assign the next available pathfinding thread to this queue item, thread will calculate the path and write it back to the memory area belonging to that queue item and set a flag that path is ready. Main game will run a critter through the path. In case of a conflict it will just request another path, nothing simpler:)
Logged
tail -f -n 10 df_27_176_38a/gamelog.txt

10ebbor10

  • Bay Watcher
  • DON'T PANIC
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #1 on: June 26, 2012, 03:43:58 pm »

Congratulations, You have succesfully made a useless and posted before thread. Please search before you post.

Spoiler: Tags to search for (click to show/hide)

1. a) It would not be simple, the above thing you suggest would crash or block/lag whenever two people enter the same square, people get scared and in combat.
    b) Toady has no multithreading experience
    c) Multithreading errors are among the worst to debug
2. Just go and read the umptheen threads that have been made about this topic already.
Logged

JanusTwoface

  • Bay Watcher
  • murbleblarg
    • View Profile
    • jverkamp.com
Re: Spin the pathfinding off to other threads.
« Reply #2 on: June 26, 2012, 03:44:10 pm »

Should probably search for that. Multithreading and pathfinding are by far two of the most common suggestions on the forum and I've already seen a few threads, pretty much identical to this one.

Forum search: multithreading; pathfinding
Google search: multithreading; pathfinding

You should read those first. It'll be more useful than posting all of the same arguments here again. While you're probably right, it's all been discussed before.

A neat trick to force Google to only include the Suggestions subforum is to add 'site:http://www.bay12forums.com/smf/index.php?board=5.0' to the search terms.
Logged
You may think I'm crazy / And I think you may be right
But life is ever so much more fun / If you are the crazy one

My blog: Photography, Programming, Writing
Novels: A Sea of Stars, Confession

aha

  • Bay Watcher
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #3 on: June 26, 2012, 03:56:20 pm »

<whiteknighting>
Congratulations, You have succesfully made a useless and posted before thread. Please search before you post.

Spoiler: Tags to search for (click to show/hide)

1. a) It would not be simple, the above thing you suggest would crash or block/lag whenever two people enter the same square, people get scared and in combat.
    b) Toady has no multithreading experience
    c) Multithreading errors are among the worst to debug
2. Just go and read the umptheen threads that have been made about this topic already.
</whiteknighting>

Pah - I do understand the issues with multi-threading - I deal with them daily.
Spinning off pathfinding is easy, especially following these simple steps. Multi-threading is not magic - what does experience have to do with it? - Toady is an intelligent fellow, he can figure it out.

DF reveal/hack can read the map, can it not? It's even easier for Toady.
Setting aside some memory for for queue is not rocket science, just couple of flags per item needed to keep it synchronised.
Wrapping the main executable into a launcher is also something that should not cause any issues.




Logged
tail -f -n 10 df_27_176_38a/gamelog.txt

DwarfMeister

  • Bay Watcher
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #4 on: June 27, 2012, 01:02:39 pm »

A LOT of people keep saying that multithreading has already been talked about, but doesn't that just mean that it's a GOOD idea? I bet before cars were invented, people kept saying stuff like, "It's way too hard to build a contraption that can replace the horse!!! Only a complete FOOL would try such a thing!!!".

I'll admit that it might be a LOT of work. The results would be worth it, however. To put it this way, how many horses do you see people riding on the freeway?

Just my two cents.
Logged

Josephus

  • Bay Watcher
  • The Immortal Historian
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #5 on: June 27, 2012, 04:50:57 pm »

The car wasn't invented by one man.

More importantly, people just don't like clutter in the Suggestions forum, and multithreading is one of the most commonly brought up topics. Every point that could possibly have been made has already been made in those threads.
Logged
Solar Rangers: Suggestion Game in SPAAAAACE
RPG Interest Check Thread
i had the elves bring me two tigermen, although i forgot to let them out of the cage and they died : ( i was sad : (

DwarfMeister

  • Bay Watcher
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #6 on: June 27, 2012, 04:58:36 pm »

The car wasn't invented by one man.

More importantly, people just don't like clutter in the Suggestions forum, and multithreading is one of the most commonly brought up topics. Every point that could possibly have been made has already been made in those threads.

Okay.
Logged

Josephus

  • Bay Watcher
  • The Immortal Historian
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #7 on: June 27, 2012, 05:00:43 pm »

<whiteknighting>

... did someone drastically alter the meaning of the term 'white knight' while I was gone?

Pretty sure it didn't used to mean 'backseat mod'.
Logged
Solar Rangers: Suggestion Game in SPAAAAACE
RPG Interest Check Thread
i had the elves bring me two tigermen, although i forgot to let them out of the cage and they died : ( i was sad : (

aha

  • Bay Watcher
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #8 on: June 28, 2012, 07:05:06 pm »

The car wasn't invented by one man.

More importantly, people just don't like clutter in the Suggestions forum, and multithreading is one of the most commonly brought up topics. Every point that could possibly have been made has already been made in those threads.

"People", who dislike clutter could easily write an userscript to hide the posts that mention multithreading:P

Anyways, I am going to gently caress DF with IDA this weekend and see if I can hook into the pathfinding loop and make it communicate with an external program.
Logged
tail -f -n 10 df_27_176_38a/gamelog.txt

Josephus

  • Bay Watcher
  • The Immortal Historian
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #9 on: June 28, 2012, 07:07:14 pm »

"People", who dislike clutter could easily write an userscript to hide the posts that mention multithreading:P

No, no they couldn't. Not everyone is a l33t code jockey, you know. The most experience the majority would have had with scripts is greasemonkey.
Logged
Solar Rangers: Suggestion Game in SPAAAAACE
RPG Interest Check Thread
i had the elves bring me two tigermen, although i forgot to let them out of the cage and they died : ( i was sad : (

aha

  • Bay Watcher
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #10 on: June 28, 2012, 07:19:52 pm »

<whiteknighting>

... did someone drastically alter the meaning of the term 'white knight' while I was gone?

Pretty sure it didn't used to mean 'backseat mod'.


Good point, I have edited and submitted the more up to date definition to the urbandictionary.com - for is it not written, that urbandictionary is the source of all knowledge?  ;)
Logged
tail -f -n 10 df_27_176_38a/gamelog.txt

aha

  • Bay Watcher
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #11 on: June 28, 2012, 07:21:23 pm »

"People", who dislike clutter could easily write an userscript to hide the posts that mention multithreading:P

No, no they couldn't. Not everyone is a l33t code jockey, you know. The most experience the majority would have had with scripts is greasemonkey.

Greasemonkey ~= userscript runner
Logged
tail -f -n 10 df_27_176_38a/gamelog.txt

Josephus

  • Bay Watcher
  • The Immortal Historian
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #12 on: June 28, 2012, 07:22:50 pm »

"People", who dislike clutter could easily write an userscript to hide the posts that mention multithreading:P

No, no they couldn't. Not everyone is a l33t code jockey, you know. The most experience the majority would have had with scripts is greasemonkey.

Greasemonkey ~= userscript runner

Yes, and they can find plenty of them on the web.

Can they write them? Likely, not.
Logged
Solar Rangers: Suggestion Game in SPAAAAACE
RPG Interest Check Thread
i had the elves bring me two tigermen, although i forgot to let them out of the cage and they died : ( i was sad : (

aha

  • Bay Watcher
    • View Profile
Re: Spin the pathfinding off to other threads.
« Reply #13 on: June 28, 2012, 07:30:10 pm »

Logged
tail -f -n 10 df_27_176_38a/gamelog.txt

Josephus

  • Bay Watcher
  • The Immortal Historian
    • View Profile
Logged
Solar Rangers: Suggestion Game in SPAAAAACE
RPG Interest Check Thread
i had the elves bring me two tigermen, although i forgot to let them out of the cage and they died : ( i was sad : (
Pages: [1] 2 3 4