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 AntLandscape

    java.lang.Object
      com.epochx.ant.AntLandscape

    public class AntLandscape

extends java.lang.Object

An `AntLandscape` provides the environment an artificial ant operates in. The landscape is essentially a torus with a given width/height, over which the positions wrap back around. The landscape also incorporates a set of food locations which define the location of food pellets within that co-ordinate system.

Constructor Summary
`AntLandscape(java.awt.Dimension size, java.util.List<java.awt.Point> foodLocations)` Constructs an AntLandscape with the given dimensions and food locations.

Method Summary
`void` | `addFoodLocation(java.awt.Point location)` Adds a new food location to the landscape.
`void` | `clearFoodLocations()` Clears all food locations on the landscape.
`int` | `getHeight()` Returns the height of the ant landscape.
`java.awt.Point` | `getNextLocation(java.awt.Point location, Orientation orientation)` Returns the location of one move on from the given location in the direction of the provided orientation.
`java.awt.Dimension` | `getSize()` Returns the size of the ant landscape.
`int` | `getWidth()` Returns the width of the ant landscape.
`boolean` | `isFoodLocation(java.awt.Point location)` Tests whether a location contains an item of food.
`boolean` | `isValidLocation(java.awt.Point location)` Tests if a location is a valid position within the landscape's dimensions.
`void` | `removeFoodLocation(java.awt.Point location)` Removes a food location from the ant landscape.
`void` | `setFoodLocations(java.util.List<java.awt.Point> foodLocations)` Replaces the current set of food locations with a new set.

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

Constructor Detail

### AntLandscape

    public AntLandscape(java.awt.Dimension size,
                        java.util.List<java.awt.Point> foodLocations)

  Constructs an AntLandscape with the given dimensions and food locations. To be reachable, foodLocations should refer to points inside the size dimensions where co-ordinate points are indexed from 0.

  Parameters:
    `size` - the width/height dimensions of the landscape.
    `foodLocations` - the location of food pellets upon the landscape.

Method Detail

### addFoodLocation

    public void addFoodLocation(java.awt.Point location)

  Adds a new food location to the landscape. The new point may not be tested to check it is a valid location within the landscape dimensions so care should be taken to provide valid locations.

  Parameters:
    `location` - the x/y co-ordinates of the new item of food.

### removeFoodLocation

    public void removeFoodLocation(java.awt.Point location)

  Removes a food location from the ant landscape. If there are multiple food pellets at the same `Point` location then only one will be removed. If no food pellet exists at the given location then this method will do nothing.

  Parameters:
    `location` - the location of a current food item to be removed.

### isFoodLocation

    public boolean isFoodLocation(java.awt.Point location)

  Tests whether a location contains an item of food.

  Parameters:
    `location` - The location in the landscape to test.
  Returns:
    true if food is present at the given location, false otherwise.

### setFoodLocations

    public void setFoodLocations(java.util.List<java.awt.Point> foodLocations)

  Replaces the current set of food locations with a new set. To be reachable, foodLocations should refer to points inside the size dimensions of the landscape where co-ordinate points are indexed from 0.

  Parameters:
    `foodLocations` - the location of food pellets upon the landscape.

### clearFoodLocations

    public void clearFoodLocations()

  Clears all food locations on the landscape.

### getSize

    public java.awt.Dimension getSize()

  Returns the size of the ant landscape.

  Returns:
    the dimensions of the ant landscape.

### getWidth

    public int getWidth()

  Returns the width of the ant landscape.

  Returns:
    the width of the ant landscape.

### getHeight

    public int getHeight()

  Returns the height of the ant landscape.

  Returns:
    the height of the ant landscape.

### isValidLocation

    public boolean isValidLocation(java.awt.Point location)

  Tests if a location is a valid position within the landscape's dimensions. Locations are indexed from 0.

  Parameters:
    `location` - the location to test.
  Returns:
    true if the location is a valid position on the landscape.

### getNextLocation

    public java.awt.Point getNextLocation(java.awt.Point location,
                                          Orientation orientation)

  Returns the location of one move on from the given location in the direction of the provided orientation. The landscape is a torus so this method is required to calculate the necessary wrapping.

  Parameters:
    `location` - the current location to calculate the next move from.
    `orientation` - the direction of the move.
  Returns:
    the next location one move on from the given location in the direction of the provided orientation.

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