Potential Fields: Movement

Click to set goal to cursor position

The above swf illustrates how potential fields can be generated with no obstacles. It is the first in a series on potential fields. It highlights how the potential field is used when determining where the agent must move next.

SWF Details

  • Goal is represented by full blue
  • Potential degrades further away from the goal (represented by gradient in blue)
  • Pink is the agent
  • SWF size 400×400 pixels
  • Grid size = 50×50 cells
  • Cell size = 8×8 pixels
  • Agents = 1
  • Goals = 1

Potential Field Generation PSEUDO Algorithm

  • Start with FIFO queue
  • Set goal cell potential to 1
  • Add goal cell position to queue
  • While the queue is not empty (tip: add in check to make sure queue does not grow larger than max cells)
  • Pop the position to be evaluated
  • Check if neighbors have been calculated
  • For each unset neighbor set neighbor = current energy * decay factor
  • For each unset neighbor add it’s position to the queue

Agent Movement PSEUDO Algorithm

  • Determine neighbor with the most energy that is also higher than current energy
  • Move agent to that neighbor’s position


If you are to represent the potential field as a vector field, then when the agent needs to determine where to move next, it only has to evaluate its current node for direction, instead of evaluating each neighbor for the highest energy neighbor.

Download the Flash Develop 4 project