vooga.aiEngine.Algorithms
Class PongAlgorithmSmart

java.lang.Object
  extended by vooga.aiEngine.Algorithms.AbstractAlgorithm
      extended by vooga.aiEngine.Algorithms.PongAlgorithmSmart

public class PongAlgorithmSmart
extends AbstractAlgorithm

PongAlgorithmSmart.java

Author:
Cody Freeman This PongAlgorithm uses a PongAIMemory to remember past collisions and positions of the target. In so doing, it allows for the calculation of an ideal position. When the ball is detected to be moving away from the ai's paddle, it will draw from previous collisions and find the average spot that the ball goes to in order to be ready to intercept the ball while moving a minimal distance. When the ball is detected to be moving towards the ai's paddle, it will project the current path of the ball and home in the position at which the ball will cross the ai paddle's x-position. Instead of using while loops to actually simulate movement of the ball, this program calculates the total x-distance the ball will travel, uses proportions to find the total y-distance the ball will travel, and then factor in the number of times that the ball would reflect off the edges of the screen in order to determine its change in position through a single calculation, rather than through a loop that would move the ball towards the ai over time.

Constructor Summary
PongAlgorithmSmart()
           
 
Method Summary
 void perform(java.lang.Object... args)
          Performs the PongAlgorithmSmart algorithm, assuming the correct parameters are presented
 
Methods inherited from class vooga.aiEngine.Algorithms.AbstractAlgorithm
performWithDelay, setDelay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PongAlgorithmSmart

public PongAlgorithmSmart()
Method Detail

perform

public void perform(java.lang.Object... args)
             throws java.lang.RuntimeException
Performs the PongAlgorithmSmart algorithm, assuming the correct parameters are presented

Specified by:
perform in class AbstractAlgorithm
Parameters:
eventFirer -
ai -
target -
movedown -
moveup -
Throws:
java.lang.RuntimeException