Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.epochx.ant
Class Ant

    java.lang.Object
      com.epochx.ant.Ant

    public class Ant

extends java.lang.Object

An Ant represents an artificial ant which exists within and can move about and perform other actions on an `AntLandscape`.

Constructor Summary
`Ant(int timeSteps, AntLandscape landscape)` Constructs an Ant object on the given landscape.

Method Summary
`void` | `eatFood()` Increments the number of food pellets the ant has eaten.
`int` | `getFoodEaten()` Returns the number of food pellets the ant has eaten.
`java.awt.Point` | `getLocation()` Returns the current location of Ant as a point in the x/y-coordinate system that represents the landscape.
`int` | `getMaxMoves()` Returns the maximum number of time steps the ant is allowed to move.
`int` | `getMoves()` Gets the number of time steps the ant has completed.
`Orientation` | `getOrientation()` Returns the direction the Ant is currently facing and travelling.
`boolean` | `isFoodAhead()` Tests whether the next location for the ant, in its current orientation on its current landscape, contains a food pellet or not.
`void` | `move()` Moves the ant's position one place in the direction it is currently facing based upon its orientation.
`void` | `reset()` Reset the ant using the same number of time steps and on the same `AntLandscape`.
`void` | `reset(int timeSteps, AntLandscape landscape)` Resets the ant, setting it up with a new number of time steps allocated and a new `AntLandscape`.
`void` | `setLocation(int x, int y)` Sets the location of the ant on its landscape using an x/y co-ordinate system.
`void` | `setOrientation(Orientation orientation)` Sets the orientation the Ant is to facing.
`void` | `skip()` Skipping will cause the ant to fill one timestep without moving in its ant landscape.
`java.lang.String` | `toString()`
`void` | `turnLeft()` Turn the ant to the left relative to its current orientation.
`void` | `turnRight()` Turn the ant to the right relative to its current orientation.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Ant

    public Ant(int timeSteps,
               AntLandscape landscape)

  Constructs an Ant object on the given landscape.

  Parameters:
    `timeSteps` - the maximum number of time steps the ant is allowed to move. Turning, moving and skipping all count as one time step.
    `landscape` - the landscape the ant will move through.

Method Detail

### reset

    public void reset(int timeSteps,
                      AntLandscape landscape)

  Resets the ant, setting it up with a new number of time steps allocated and a new `AntLandscape`.

  Parameters:
    `timeSteps` - the maximum number of time steps the ant is allowed to move. Turning, moving and skipping all count as one time step.
    `landscape` - the landscape the ant will move through.

### reset

    public void reset()

  Reset the ant using the same number of time steps and on the same `AntLandscape`.

### turnLeft

    public void turnLeft()

  Turn the ant to the left relative to its current orientation. For example, if calling getOrientation() returns EAST before calling this method it will return NORTH after calling this method. If the ant has reached its maximum number of allowed time steps then this method will do nothing.

### turnRight

    public void turnRight()

  Turn the ant to the right relative to its current orientation. For example, if calling getOrientation() returns EAST before calling this method it will return SOUTH after calling this method. If the ant has reached its maximum number of allowed time steps then this method will do nothing.

### move

    public void move()

  Moves the ant's position one place in the direction it is currently facing based upon its orientation. If the ant's new location on the landscape contains a food pellet then the ant will attempt to eat it. If the ant has reached its maximum number of allowed time steps then this method will do nothing.

### eatFood

    public void eatFood()

  Increments the number of food pellets the ant has eaten.

### getLocation

    public java.awt.Point getLocation()

  Returns the current location of Ant as a point in the x/y-coordinate system that represents the landscape.

  Returns:
    the current location of the ant as a `Point`.

### setLocation

    public void setLocation(int x,
                            int y)

  Sets the location of the ant on its landscape using an x/y co-ordinate system.

  Parameters:
    `x` - the x axis location of the ant.
    `y` - the Y axis location of the ant.

### getMoves

    public int getMoves()

  Gets the number of time steps the ant has completed. Turning, moving and skipping all count as one time step.

  Returns:
    The number of time steps the ant has gone through.

### getFoodEaten

    public int getFoodEaten()

  Returns the number of food pellets the ant has eaten.

  Returns:
    The number of food pellets the ant has eaten.

### getOrientation

    public Orientation getOrientation()

  Returns the direction the Ant is currently facing and travelling.

  Returns:
    a compass orientation indicating the direction the ant is currently facing.

### setOrientation

    public void setOrientation(Orientation orientation)

  Sets the orientation the Ant is to facing. This is the direction the ant will proceed in if the move method is called next.

  Parameters:
    `orientation` - The new orientation the ant is to face.

### isFoodAhead

    public boolean isFoodAhead()

  Tests whether the next location for the ant, in its current orientation on its current landscape, contains a food pellet or not.

  Returns:
    true if the position in front of the ant contains a food pellet and false otherwise.

### skip

    public void skip()

  Skipping will cause the ant to fill one timestep without moving in its ant landscape. This is required for the skip algorithm to prevent the ant falling into dead ends.

### getMaxMoves

    public int getMaxMoves()

  Returns the maximum number of time steps the ant is allowed to move. Turning, moving and skipping all count as one time step.

  Returns:
    the maximum number of time steps the ant is allowed to move

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD