apes
Class EnemyAIMedium

java.lang.Object
  extended by apes.AbstractEnemyAI
      extended by apes.EnemyAIMedium
All Implemented Interfaces:
IEnemyAI

public class EnemyAIMedium
extends AbstractEnemyAI
implements IEnemyAI

This *AI* is smarter than the Simple one. It adjusts the range in which random number are found according to the last impact and the position of the enemy. What it does not do: check for walls. so it can happen, that it gets stuck and does not stop throwing things against the wall, never trying a wider range again.


Field Summary
 org.newdawn.slick.geom.Shape hitArea
          area that can be covert by min/max values.
 
Fields inherited from class apes.AbstractEnemyAI
currentThinking, gc, map, MAXBETA, MAXTHINKINGTIME, MAXVELOCITY, MINBETA, MINTHINKINGTIME, MINVELOCITY
 
Constructor Summary
EnemyAIMedium(BlockMap map)
          constructs a new medium ai.
 
Method Summary
 float calculateBeta()
          returns a random beta value in between the current min/max values as defined by the call to reCalculateMinMaxBeta.
 float calculateVelocity()
          returns a random velocity value in between the current min/max values as defined by the call to reCalcualteMinMaxVel.
 void calculateVelocityBeta()
          calculates angles which will be returned by getBeta and getVelocity.
protected  void correctCalculations()
           
protected  float diffTo45(float angle)
           
 float getBeta()
          returns an angle that should be used in a throw.
 float getVelocity()
          returns a velocity that should be used in a throw.
protected  boolean isHitPossible(float minBeta, float minVel, float maxBeta, float maxVel)
          returns weather or not the enemy can be hit with some value between the given min/max values.
protected  void reCalcualteMinMaxVel()
          see reCalculateMinMaxBeta but for the velocity.
protected  void reCalculateMinMaxBeta()
          checks if the place, where the banana landed last is bevor or behind the players ape and sets either the currentMinBeta or currentMaxBeta to the beta value of that previous throw.
 
Methods inherited from class apes.AbstractEnemyAI
executeNextMove, randomBetween
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface apes.IEnemyAI
executeNextMove
 

Field Detail

hitArea

public org.newdawn.slick.geom.Shape hitArea
area that can be covert by min/max values.

Constructor Detail

EnemyAIMedium

public EnemyAIMedium(BlockMap map)
constructs a new medium ai.

Parameters:
banana -
Method Detail

calculateVelocityBeta

public void calculateVelocityBeta()
Description copied from class: AbstractEnemyAI
calculates angles which will be returned by getBeta and getVelocity.

Specified by:
calculateVelocityBeta in class AbstractEnemyAI

getBeta

public float getBeta()
Description copied from class: AbstractEnemyAI
returns an angle that should be used in a throw.

Specified by:
getBeta in class AbstractEnemyAI
Returns:

getVelocity

public float getVelocity()
Description copied from class: AbstractEnemyAI
returns a velocity that should be used in a throw.

Specified by:
getVelocity in class AbstractEnemyAI
Returns:

calculateBeta

public float calculateBeta()
returns a random beta value in between the current min/max values as defined by the call to reCalculateMinMaxBeta.

Returns:

calculateVelocity

public float calculateVelocity()
returns a random velocity value in between the current min/max values as defined by the call to reCalcualteMinMaxVel.

Returns:

reCalculateMinMaxBeta

protected void reCalculateMinMaxBeta()
checks if the place, where the banana landed last is bevor or behind the players ape and sets either the currentMinBeta or currentMaxBeta to the beta value of that previous throw. If the new current min/max value results in the case, that the enemy cannot be hit anymore, it will not be set.


reCalcualteMinMaxVel

protected void reCalcualteMinMaxVel()
see reCalculateMinMaxBeta but for the velocity.


isHitPossible

protected boolean isHitPossible(float minBeta,
                                float minVel,
                                float maxBeta,
                                float maxVel)
returns weather or not the enemy can be hit with some value between the given min/max values.

Parameters:
minBeta -
minVel -
maxBeta -
maxVel -
Returns:

diffTo45

protected float diffTo45(float angle)

correctCalculations

protected void correctCalculations()