org.vizzini.example.ant
Class AntContext

java.lang.Object
  extended by org.vizzini.ai.geneticalgorithm.AbstractContext
      extended by org.vizzini.example.ant.AntContext
All Implemented Interfaces:
IContext

public class AntContext
extends AbstractContext

State variables: x - ant x position y - ant y position heading - ant heading [north,east,south,west] t - time food - number of food pellets consumed

Author:
Jeffrey M. Thompson

Field Summary
static String GRID_NAME
          State variable name for the grid.
static String HEADING_NAME
          State variable name for the ant heading.
static String POSITION_NAME
          State variable name for the position.
static String TIME_NAME
          State variable name for time.
 
Constructor Summary
AntContext()
          Construct this object.
 
Method Summary
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Add a PropertyChangeListener for a specific property.
protected  void addToStateVariable(String name, int delta)
          Add the given delta to the specified state variable.
 void decrementX()
          Decrement X.
 void decrementY()
          Decrement Y.
 int getFood()
          Return food.
 Grid getGrid()
          Return grid.
 String getHeading()
          Return heading.
 IntegerPosition getPosition()
          Return position.
 int getTime()
          Return time.
 void incrementTime()
          Increment the time state variable.
 void incrementX()
          Increment X.
 void incrementY()
          Increment Y.
 void initialize()
          Initialize the state of the context.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Remove a PropertyChangeListener for a specific property.
 void setAnt()
          Set the ant at the x, y coordinates.
 void setFootprint()
          Set a footprint at the x, y coordinates.
 void setHeading(String heading)
          Set heading.
 void setPosition(int x, int y)
          Set position.
protected  void setTime(int time)
          Set time.
 
Methods inherited from class org.vizzini.ai.geneticalgorithm.AbstractContext
add, getCurrentFitnessCase, getCurrentFitnessCaseIndex, getFitnessCaseCount, getStateVariable, incrementCurrentFitnessCase, reset, setStateVariable, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GRID_NAME

public static final String GRID_NAME
State variable name for the grid.

See Also:
Constant Field Values

POSITION_NAME

public static final String POSITION_NAME
State variable name for the position.

See Also:
Constant Field Values

HEADING_NAME

public static final String HEADING_NAME
State variable name for the ant heading.

See Also:
Constant Field Values

TIME_NAME

public static final String TIME_NAME
State variable name for time.

See Also:
Constant Field Values
Constructor Detail

AntContext

public AntContext()
Construct this object.

Since:
v0.3
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property.

Parameters:
propertyName - The name of the property to listen on.
listener - The PropertyChangeListener to be added.
Since:
v0.3

decrementX

public void decrementX()
Decrement X.

Since:
v0.3

decrementY

public void decrementY()
Decrement Y.

Since:
v0.3

getFood

public int getFood()
Return food.

Since:
v0.3

getGrid

public Grid getGrid()
Return grid.

Since:
v0.3

getHeading

public String getHeading()
Return heading.

Since:
v0.3

getPosition

public IntegerPosition getPosition()
Return position.

Since:
v0.3

getTime

public int getTime()
Return time.

Since:
v0.3

incrementTime

public void incrementTime()
Increment the time state variable.

Since:
v0.3

incrementX

public void incrementX()
Increment X.

Since:
v0.3

incrementY

public void incrementY()
Increment Y.

Since:
v0.3

initialize

public void initialize()
Initialize the state of the context.

Since:
v0.3

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property.

Parameters:
propertyName - The name of the property that was listened on.
listener - The PropertyChangeListener to be removed.
Since:
v0.3

setAnt

public void setAnt()
Set the ant at the x, y coordinates.

Since:
v0.3

setFootprint

public void setFootprint()
Set a footprint at the x, y coordinates.

Since:
v0.3

setHeading

public void setHeading(String heading)
Set heading.

Since:
v0.3

setPosition

public void setPosition(int x,
                        int y)
Set position.

Since:
v0.3

addToStateVariable

protected void addToStateVariable(String name,
                                  int delta)
Add the given delta to the specified state variable.

Parameters:
name - State variable name.
delta - Amount to add.
Since:
v0.3

setTime

protected void setTime(int time)
Set time.

Since:
v0.3


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02