|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.epochx.ant.AntLandscape
public class AntLandscape
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 |
|---|
public AntLandscape(java.awt.Dimension size,
java.util.List<java.awt.Point> foodLocations)
size - the width/height dimensions of the landscape.foodLocations - the location of food pellets upon the landscape.| Method Detail |
|---|
public void addFoodLocation(java.awt.Point location)
location - the x/y co-ordinates of the new item of food.public void removeFoodLocation(java.awt.Point location)
Point location then only one will
be removed. If no food pellet exists at the given location then this
method will do nothing.
location - the location of a current food item to be removed.public boolean isFoodLocation(java.awt.Point location)
location - The location in the landscape to test.
public void setFoodLocations(java.util.List<java.awt.Point> foodLocations)
foodLocations - the location of food pellets upon the landscape.public void clearFoodLocations()
public java.awt.Dimension getSize()
public int getWidth()
public int getHeight()
public boolean isValidLocation(java.awt.Point location)
location - the location to test.
public java.awt.Point getNextLocation(java.awt.Point location,
Orientation orientation)
location - the current location to calculate the next move from.orientation - the direction of the move.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||