User:KyleHatch/Potential function based movement

Potential Function Based Movement
Introduction:

-Potential function-based movement refers to using potential functions as an AI technique to create movement in games. -Movement can include chasing, evading, obstacle avoidance and even swarming. -Potential functions are essentially concepts from Physics, and the particular potential function being discussed is called Lenard-Jones potential function.

Potential Function and its application in game AI:

-The underlying concept is to calculate the force between two units (e.g. computer-controlled unit and player) and apply the force to one end of a unit (computer-controlled unit in this case).

-The force can be applied to either the front end or the rear end depending on whether chasing or evading needs to be achieved respectively.

-This force is known as the steering force and it contributes to the propulsive force or the thrust of the unit.

-The Lenard Jones potential function is given as U = - A / rn + B / rm and is used to represent the potential energy of attraction and repulsion of molecules in Physics, where U is the potential energy, inversely proportional to the separation distance, r, between the molecules, A and B are parameters and m and n are exponents.

-The function representing force is obtained by taking the derivative of this potential function. -F = - dV / dr = - nA / rn+1 + mB / rm+1, where A, B, n and m are parameters chosen depending on the material under consideration.

-The same force function produces both the attractive and the repulsive forces depending on the proximity of the molecules.

-The term involving A and n represents the attractive force component and the term involving B and m represents the repulsive force component.

-A and B represent the magnitude of the forces whereas n and m represent the attenuation of the force components.

-The attractive force acts over a larger distance and has a relatively lower magnitude, and the repulsive force acts over a relatively smaller distance and has a larger magnitude. -In the case of game AI, the molecules are replaced with computer-controlled units, the attractive force represents chasing and the repulsive force represents evading.

-The attractive force can also be used to represent swarming and the repulsive force can also be used to represent obstacle avoidance.

Chasing and Evading:

- Quite simple to see, but the reason to implement this using potential function instead of the more traditional way is the ease of use to change from one state to the next dependant on scenario, for example if you NPC see’s you and knows you’re the enemy but that your really good he might evade, but as other NPC’s turn up he’ll feel more confident and the parameters change so that he changes to a chase or attack frame of mind.

Obstacle Avoidance: -In the case of obstacle avoidance, the obstacles repel the computer-controlled units when they get too close, causing them to steer away.

-In order to achieve this, the attractive force component is set to 0, leaving only the repulsive force component.

-The B and m parameter can then be set to the required strength and attenuation.

-The closer the object is to the obstacle, the greater the repulsive force.

Crowd Movement:

-In the case of crowd movement, the computer-controlled units attract each other to create the idea that they are not avoiding each other, but repel each other to prevent them from colliding.

-This is performed by calculating the Lenard-Jones force between each unit in the swarm.

Swarming:

-Similar to crowd movement just a bit more intense. The units would be closer together and there would be the occasional colliding.

Advantages:

-The primary advantage of using potential functions is that a single function can be used to for both chasing and evading without any extra conditions or logic.

-Another advantage is that it is very simple to implement.

Disadvantage:

- It is very CPU intensive, so has to be cut to a small area of your game world at any one time.

References

Book

AI for Game Developers by David M Bourg, Glenn Seemann (very good book worth a purchase with alot of good AI topics in it.

Web

http://en.wikipedia.org/wiki/Lennard-Jones_potential

http://www.cse.scu.edu/~mwang2/game/GameAI.pdf

http://www.stat.berkeley.edu/~brill/Papers/jqas.pdf