Unit formation with Potential Function

Added cross-unit forces calculation loop to the Potential Function algorithm. There are still two serious bug that I know of, one of which result in infinite loop that froze the game.

Much like how I did with A* algorithm, the inter-unit force calculations are now performed in the background by GameNavigator class, which constantly looping through the entire grid and perform calculation for a specific number of cells per frame, every frame, ensuring that these calculations will not be hogging the resources by trying to do everything in a single frame. In addition, by using a single function running in the background rather than separately in each unit, the code could be optimized to reduce the number of calculations while requiring only a single temporary variable per unit to keep track what has been calculated.

Writing this at midnight, so the text could be confusing…


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