Re: multithreading for pathfinding?
- From: "Jan Bruns" <testzugang_janbruns@xxxxxxxx>
- Date: Tue, 23 May 2006 21:38:43 +0200
If your pathfinding algo takes that long for a single static path,
I'd suggest to work it over. Maybe you can limit the maximum distance,
or heavily reduce details about the scene.
Details only really matter if they're near to the actor. Small
impedimentson the way, wich an actor will have to pass in some
about some seconds shouldn't too much affect it's actual way.
Furthermore you probably want to take dynamic changes to th scene
into account.
So better often use a fast algo to find a rough idea about the path
to choose, and let physics/objectmanagers/whatever focus on the detail.
I don't see your point in thread-friendlyness of DX.
Pathfinding should be done in a separate thread to make use of
Multiple CPUs, but designing a good algo is much more important,
of course. Think about ensureing a minimum path quality somewhere
near to where you'd query results.
Gruss
Jan Bruns
<nospam@xxxxxxxxxx> schrieb im Newsbeitrag news:e4viba02ing@xxxxxxxxxxxxxxxxxxxx
Hello,.
I have a role-playing game and I've implemented a simple pathfinding
algorithm (navigate a character from point A to point B avoiding
obstacles). Currently, path-finding is only done for NPC (non-player-
characters) and is performed during combat to get the NPC close enough to
the player to attack.
The problem is that this path-finding algorithm takes a bit of time --
maybe up to a couple of seconds. If implemented in it's entirety inside of
the render loop, it will cause rendering to pause. This leaves me with two
obvious alternatives:
1) Modify the algorithm to do an incremental amount of work per frame,
rather than compute a whole path.
2) Use a seperate thread to do the path-finding, and let the scheduler
sort it out.
The disadvantage of #1 is that I have to figure out how much "work" can be
done per frame -- should I pick a fixed amount of "work" per frame, or
pick a fixed amount of "time" per frame to run the algorithm? (i.e. let it
run long enough to check n collisions, or let it check as many collisions
as it can in n milliseconds)...
The disadvantage of #2 is that DX isn't all that thread-friendly -- for
example, Present() uses a spin-wait for VSYNC to occur, and no threads can
run while it's spin-waiting. Similarly, letting the scheduler sort things
out can lead to unpredictable performance. Another disadvantage is having
to throw locks all over the code.
I'm leaning toward alternative #1 due to the relative simplicity in
implementation.
Anyhow, I'm wondering if anyone in this group has any thoughts on the
subject...
Thanks
Scott
-----------------------------------------------------------
Posted using Android Newsgroup Downloader:
.... http://www.sb-software.com/android
-----------------------------------------------------------
- Follow-Ups:
- Re: multithreading for pathfinding?
- From: nospam
- Re: multithreading for pathfinding?
- References:
- multithreading for pathfinding?
- From: nospam
- multithreading for pathfinding?
- Prev by Date: Re: multithreading for pathfinding?
- Next by Date: Re: multithreading for pathfinding?
- Previous by thread: Re: multithreading for pathfinding?
- Next by thread: Re: multithreading for pathfinding?
- Index(es):
Relevant Pages
|