Class RandomWalkingBrain

java.lang.Object
  extended by RandomWalkingBrain
All Implemented Interfaces:
IBeastBrain

public class RandomWalkingBrain
extends java.lang.Object
implements IBeastBrain

A beast that takes a random walk around the screen, getting less intense the older it gets and happier the further it is from whatever point it's at the first time getMood is called (which is not necessarily its starting point, but probably is).

Author:
CPSC 111 instructors

Field Summary
static double AGE_RATE
          Number of time steps it takes for intensity to fade.
static double PERFECT_GROOVINESS_DISTANCE
          The distance beyond which the beast is perfectly happy.
 
Constructor Summary
RandomWalkingBrain()
           
 
Method Summary
 Direction chooseDirection(BeastInfo me, IPackFinder packFinder)
          Choose a direction at random.
 BeastMood chooseMood(BeastInfo me, IPackFinder packFinder)
          Choose a mood based on my distance from the first point where I was created.
 double getFirstX()
           
 double getFirstY()
           
 boolean isInitialized()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERFECT_GROOVINESS_DISTANCE

public static double PERFECT_GROOVINESS_DISTANCE
The distance beyond which the beast is perfectly happy.


AGE_RATE

public static double AGE_RATE
Number of time steps it takes for intensity to fade.

Constructor Detail

RandomWalkingBrain

public RandomWalkingBrain()
Method Detail

chooseDirection

public Direction chooseDirection(BeastInfo me,
                                 IPackFinder packFinder)
Choose a direction at random.

Specified by:
chooseDirection in interface IBeastBrain
Parameters:
me - information about this beast (what its brain knows about its body/state), must be non-null
packFinder - a pack finder to tell this beast about its pack (must be non-null)
Returns:
a chosen direction to go next (non-null)

chooseMood

public BeastMood chooseMood(BeastInfo me,
                            IPackFinder packFinder)
Choose a mood based on my distance from the first point where I was created. Intensity goes down with age.

Specified by:
chooseMood in interface IBeastBrain
Parameters:
me - information about this beast (what its brain knows about its body/state), must be non-null
packFinder - a pack finder to tell this beast about its pack (must be non-null)
Returns:
a chosen mood to assume next, non-null

getFirstX

public double getFirstX()
Returns:
Returns the beast's first x coordinate (if it has been initialized)

getFirstY

public double getFirstY()
Returns:
Returns the beast's first y coordinate (if it has been initialized).

isInitialized

public boolean isInitialized()
Returns:
Returns whether the starting point has been initialized.