Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BeanDog

simple pathfinding

This topic is 6932 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Also, instead of trying to fulfill all pathfinding requests at once, consider doing it in 2 stages: the order to move a unit from A to B generates a Pathfinding request, which you add to a queue. Then elsewhere in your game loop, the Pathfinder picks off these requests and deals with them. You can then limit it to only dealing with 10 requests per frame, or limit it to only spending a certain number of milliseconds dealing with requests. That way, your frame rate / game speed won''t have to visibly drop. The only difference is that certain units will remain still for a little while longer, but this is rarely an issue when you have 50 moving at once.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Hi

I''ve the same problem you have *g*

I have a* implemented, but it is still to slow to move ~100 untis. Putting pathfinding in a thread doesn''t work too (gameslowdown 99% (

what you have to do is ''cheating'', finding a way to speed it up.. I thougt about pre-calulated path (like aas in q3), but haven''t found a way to do it.

if you find an solution, i''d be grateful if you tell us/me how you did it )

safti@safti.de
www.safti.de

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You could speed it up A* by improving the efficieny of the implementation, preprocessing the seach space, and buffering paths found.

a)I dont know how you implemented it so i can''t comment, but if you search here http://www-cs-students.stanford.edu/~amitp/gameprog.html for some implentations of A* you can compare your implementations

b)You could do like one poster suggest and prune the search space down using a quad-tree approach, or if your more ambitious decompose your search space into a voronoi diagram.

c)Basiclly A* is computationally very intensive, and if you buffer paths you can take advantage of the coherency of start and goal postions. For instance if 2 entities start close to each other and their goals are close to each otehr too, you can compute A* for one, and use it for the other too. Just make sure you find the path from one''s start position to the others and the same for the goal, which should be computationlly smaller since they are closer. Depending upon your memeory liminitation, you could buffer in 100''s of paths which should give you signigicant performance improvements if there is good coherency. If not you get worse case, either way.

Good Luck

-ddn

Share this post


Link to post
Share on other sites
Sorry i see u got it too hard...my prev message to u...

hmmm i just wanted to say that even if i cant tell u (because of contracts...not that i dont want to )
to open ur mind to diffrent approach than A* with everybody thinks is best but is not....

Now i feel like i have to help u a little so u dont get mad at me:

whatever algorithm u use....
1.First
u can use it once to find the path then store all points in a vector then use that vector to move units until eventually a obstacle is found...in this case redo the pathfind....
2.Second
Dont do "whatever algo u use" for all units at once...better do one unit at a cycle...
so if u have 50 units unit 1 will start then next cycle unit 2 will start...u get the picture....this will make units remain a little late....but ALL Realtime games make it one way or the other...

Hope this helps
Sorry again didnt wanted to make u mad....

Bogdan

Share this post


Link to post
Share on other sites
Check out my pathfinding algorithm. Totally precalculated and definitely the worlds fastest pathfinding algorithm .

http://www.kolumbus.fi/hannes.k/tip2b.htm

Well my algorithm isn''t maybe simple to implement, but it''s hell fast. It takes only one memory read to move a unit one step towards it''s goal, using almost optimal path!

The idea behind it is quite simple though and needs lots of thinking still, but you might be interested. Dynamicy is a problem with this algorithm, because everything is precalculated. However, it IS possible to make dynamic parts but it needs some extra work if there are dynamic parts on the route..

The algo can also solve any maze and no matter how complex map, equally fast.

-Hans

Share this post


Link to post
Share on other sites
Hey,

Last year I did a project on this topic with a few friends for my course Datastructures & Algorithms II.

It features a state of the art report on holonomic motion planning with several basic algorithms.

There''s one drawback, the project is written in Dutch (sorry guys), but I''ve also added a Visual Basic program which should visualize what I do and the algorithms are open-source.

Let me know what you think about it!

******************************
Stefan Baert

On the day we create intelligence and consciousness, mankind becomes God.
On the day we create intelligence and consciousness, mankind becomes obsolete...
******************************

Share this post


Link to post
Share on other sites
Woops, you can access the page form my homepage of course, but here is the direct link:

http://www.softline.be/StrategicAlliance/RUG/MotionPlanning/

******************************
Stefan Baert

On the day we create intelligence and consciousness, mankind becomes God.
On the day we create intelligence and consciousness, mankind becomes obsolete...
******************************

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you want to speed up A* a little, you can put a limit on the number of
precalculated waypoints that you can do. So if you have a very long path,
for example, from one side of the map to the another, the unit will precalculate
a couple waypoints, follow that path, and then precalculate another, etc..
until it reaches its target.

The only downside to this is that if you limit the number of waypoints too
much, the unit might not be able to get out of a tight space like a half
circle area.

Another speedup is limiting the number of directions that the unit can use.
16 directions is kinda slow, 8 directions is ok, but using only 4 directions
is much faster. It''s computationally less searching.

Share this post


Link to post
Share on other sites
OK, here''s how I do it. I have a search algorithm that goes directly toward the goal until it hits something. Then it splits up into 2 searches, going opposite directions around the obstacle. As soon as a dead end is it, that search is eliminated. This is a very fast method. When you first move a creature, I calculate the first about 50 squares in the path and store them in the creature itself. When it gets to the end of that 50, I calculate the next 50, etc until the unit gets to the destination. This is pretty darn fast, but not fast enough. I will try implementing how I will just do one per frame, but that will be a problem when the units get to the end of their 50-square process and have nowhere to go.

Thanks for all the advice, and when I have time I''ll check out your super-fast algorithm, Hans. I have a feeling it will be very memory- intensive, though, especially for large maps (256x256 and up).

~BenDilts( void );

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!