Sign in to follow this  

A* algorithm and a strategy game

This topic is 3844 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

Hello everyone. I am working on a 2D strategy game and I have a question. I trying implementing A* algorithm as described in the tutorial on this site. The paths calculated are very nice but there is a problem which ofcourse I expected. Too much cpu power because of map size and unit numbers all calculating paths at the same time. I have read and am still reading and trying to implement in my game everything I find on the web and also in that tutorial to make it faster to run the A* algorithm. But the question of this topic is very easy. Is all this in vain? Is there a better pathfinding algorithm used specifically for strategy games where there are supposed to be a lot of units calculating paths or should I just continue trying to improve the algorithm's performance? Thanks in advance people :)

Share this post


Link to post
Share on other sites
Hi, A* is fast. if your map has like 300 X 300 cells or more try breaking up the path before you run the A* run a straight line test and see where if any thing is in its path first if so vector to that point while running the A* in the back ground.

and make a path manager that can hold many path in some queue or something so when a unit needs to go some where it first see if there is a path allready in the pathmanager which is close to the dest of the current uints path and use that one allready used and when it get to the end it can calculate a new path to get to where it was going which in turn would me near the target location.

Share this post


Link to post
Share on other sites
Maybe it is because each unit divided the map into nodes/squares/areas according to its V(speed), so the smaller the speed the more nodes it creates to calculate the path.


EDIT: I found it :)

The problem was deep in my program logic. I divided the map constantly and stored it in a quad tree ... until we got to a pixel level. And worked everything from pathfinding to collision detetion in pixel level.

I just need to divide the map to small squares like 1/2 of my smallest tile or something instead of pixel per pixel and everything will work fine, I hope.

[Edited by - Fukushuusha on June 8, 2007 5:12:52 AM]

Share this post


Link to post
Share on other sites

This topic is 3844 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this