Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

A* pathfinding too slow


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 polyfrag   Members   -  Reputation: 670

Like
0Likes
Like

Posted 02 September 2012 - 01:10 AM

Does anybody know why my pathfinding is so slow?

http://corpstates.my.../CorpStates.zip

I divide the world into tiles based on the unit's radius and plot a route in this grid.

For each tile it checks, it checks for collisions with all units and buildings, which is why it's so slow, because there's so many small tiles to check.

Games like Age of Empires have to do more complex pathfinding and they aren't anywhere as laggy as mine.

Edited by polyfrag, 02 September 2012 - 01:11 AM.

Y̞͎̗̏ͨ̂͠o͎̩͓̠͗͘u̠̠̼̪̱̲̓̆͆̌̓̑ͦ
ͨ̌̀w̫̟̖̖̞ǐ̯̱̪͖l͂ͧ̈́͂́ͯ҉̹̘͔ͅl̜̲̘͍͖̈́̇̑͐͑͋
̝̖͐̎͊ͅb̠̟̭͉̘̭ͭ͜ͅe̙͇̝̖ͫ


Ad:

#2 Hodgman   Moderators   -  Reputation: 13463

Like
1Likes
Like

Posted 02 September 2012 - 01:30 AM

Maybe you should post your A* code?

For each tile it checks, it checks for collisions with all units and buildings, which is why it's so slow, because there's so many small tiles to check.

Maybe you could check the tiles for collisions in advance (e.g. generate another array which contains true/false for passable/not-passable for each tile) before doing any path-finding, so that the two procedures are distinct.

#3 jefferytitan   Members   -  Reputation: 1006

Like
1Likes
Like

Posted 02 September 2012 - 03:13 AM

Agreed. For grid/graph based pathfinding you never want to do collision detection in the inner loop except perhaps for dynamic objects. You construct your graph to contain all that connectivity info so you don't need to.

#4 nfries88   Members   -  Reputation: 240

Like
0Likes
Like

Posted 02 September 2012 - 05:22 AM

If your game is fairly dynamic (IE, the results of a collision test on each tile are going to change frequently), one option would be to find a means of pathfinding asynchronously.
Looking for paid or open-source C++ programming work. Been programming since 2005. No degree.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS