A* Algorithm Optimizations

It is seems that part of the Out-of-Memory problem came from the fact that cells are re-traced more than one time for multiple possible routes. To solve this problem, an Opened Cells flag array is implemented; When a cell is calculated for possible route, the flag is set ensuring it won’t be recalculated again. And to further prevent unneccessary route trace, the A* heuristic function now take into account the current cell’s weight. Although this could result in less than optimal route, it also ensure a route is found much faster.

Implementation of Open Cells flag array result in elimination of lag spikes found in previous tests;

  • Memory usage dropped by 85% from 220 MB down to 34 MB
  • Process time dropped from 80% in spikes to an insignificant value of less than 5%

Overall, the algorithm optimization result prove to be much more successful than expected. More CPU intensive algorithm might now be added with much less worry than before.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s