|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uk.ac.nott.cs.g54dia.library.Environment
public class Environment
An infinite grid of cells representing the current state of the environment at a given timestep.
Each cell in the Environment implements the Cell
interface.
Field Summary | |
---|---|
private CellFactory |
cfactory
CellFactory which is called to generate new environment. |
private java.util.Map<Point,Cell> |
map
Mapping from an (x,y) point to a Cell. |
java.util.ArrayList<Station> |
stations
List of stations |
private long |
timestep
Current timestep of the simulation. |
Constructor Summary | |
---|---|
Environment(int size)
|
|
Environment(int size,
CellFactory factory)
Initialises the Tanker environment. |
Method Summary | |
---|---|
private void |
generateTasks()
|
Cell |
getCell(Point pos)
Get the cell at a specified location |
long |
getTimestep()
Get the current timestep. |
Cell[][] |
getView(Point pos,
int size)
Return the cells a Tanker can see. |
void |
putCell(Cell c)
Add a cell to the environment. |
void |
tick()
Increase timestep. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Map<Point,Cell> map
private CellFactory cfactory
private long timestep
public java.util.ArrayList<Station> stations
Constructor Detail |
---|
public Environment(int size, CellFactory factory)
size
- size of the initial environmentfactory
- factory used to create new cellspublic Environment(int size)
Method Detail |
---|
public Cell[][] getView(Point pos, int size)
pos
- position of the Tankersize
- distance the Tanker can see
public Cell getCell(Point pos)
pos
- coordinates of the cellpublic long getTimestep()
public void tick()
public void putCell(Cell c)
c
- cell to be addedprivate void generateTasks()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |