apes
Class AbstractEnemyAI

java.lang.Object
  extended by apes.AbstractEnemyAI
All Implemented Interfaces:
IEnemyAI
Direct Known Subclasses:
EnemyAIMedium, EnemyAIMediumBACKUP, EnemyAIMediumRewrite, EnemyAISimple

public abstract class AbstractEnemyAI
extends java.lang.Object
implements IEnemyAI

An abstract implementation of the IEnemyAI interface. If executeNextMove is called, it checks if the banana is still moving, or if a throw was already started. If so it returns immediately. Otherwise, it checks weather or not it still needs to think about its next move. If so, it will again do nothing. If it is called and does know what it wants to to, it calls the calculateBeta and calculateVelocity methods (which must be implemented in a sub-class) and starts a throw with the provided values.

Currently, it is assumed, that the ai stands to the right of the player. If this is not desired, the MIN and MAX values in this code must be changed.


Field Summary
protected  int currentThinking
          current thinking time.
protected  org.newdawn.slick.GameContainer gc
           
protected  BlockMap map
           
protected static float MAXBETA
          maximal allowed beta.
protected  int MAXTHINKINGTIME
          minimal thinking time the ai should have.
protected static float MAXVELOCITY
          maximal allowed velocity.
protected static float MINBETA
          minimal allowed beta.
protected  int MINTHINKINGTIME
          maximal thinking time the ai should have.
protected static float MINVELOCITY
          minimal allowed velocity.
 
Constructor Summary
AbstractEnemyAI(BlockMap map)
          constructs a new ai that controlls the given banana.
 
Method Summary
abstract  void calculateVelocityBeta()
          calculates angles which will be returned by getBeta and getVelocity.
 void executeNextMove(float time, org.newdawn.slick.GameContainer gc)
          if the banana is not moving, it will check if it wants to make a new throw.
abstract  float getBeta()
          returns an angle that should be used in a throw.
abstract  float getVelocity()
          returns a velocity that should be used in a throw.
protected static int randomBetween(int start, int end)
          returns a random integer in between start and end.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXTHINKINGTIME

protected int MAXTHINKINGTIME
minimal thinking time the ai should have.


MINTHINKINGTIME

protected int MINTHINKINGTIME
maximal thinking time the ai should have.


MINVELOCITY

protected static final float MINVELOCITY
minimal allowed velocity.

See Also:
Constant Field Values

MINBETA

protected static final float MINBETA
minimal allowed beta.

See Also:
Constant Field Values

MAXVELOCITY

protected static final float MAXVELOCITY
maximal allowed velocity.

See Also:
Constant Field Values

MAXBETA

protected static final float MAXBETA
maximal allowed beta.

See Also:
Constant Field Values

currentThinking

protected int currentThinking
current thinking time. Each time the executeNextMove method is called, it will be reduced by one.


gc

protected org.newdawn.slick.GameContainer gc

map

protected BlockMap map
Constructor Detail

AbstractEnemyAI

public AbstractEnemyAI(BlockMap map)
constructs a new ai that controlls the given banana.

Parameters:
banana -
Method Detail

executeNextMove

public final void executeNextMove(float time,
                                  org.newdawn.slick.GameContainer gc)
if the banana is not moving, it will check if it wants to make a new throw. If so, it will do so with the velocity and beta values provided by the abstract methods in this class.

Specified by:
executeNextMove in interface IEnemyAI
Parameters:
time -
gc -

randomBetween

protected static int randomBetween(int start,
                                   int end)
returns a random integer in between start and end. start and end may be negative, but end must always be bigger than start. If it is not, end - start will be returned

Parameters:
start -
end -
Returns:

calculateVelocityBeta

public abstract void calculateVelocityBeta()
calculates angles which will be returned by getBeta and getVelocity.


getBeta

public abstract float getBeta()
returns an angle that should be used in a throw.

Returns:

getVelocity

public abstract float getVelocity()
returns a velocity that should be used in a throw.

Returns: