|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.repastdemos.life.LifeSpace
public class LifeSpace
A grid space for LifeAgents. Agents inhabit the grid cells. This class is responsible for creating new LifeAgents in those cells that have 3 and only 3 LifeAgents for neighbors. This is a bounded grid, that is optionally toriodal.
| Constructor Summary | |
|---|---|
LifeSpace(int xSize,
int ySize,
boolean toriodal,
LifeModel model)
Creates this LifeSpace of the specified width (xSize) and height (ySize). |
|
| Method Summary | |
|---|---|
void |
addAgent(LifeAgent agent)
Adds the agent at its coordinates. |
Displayable |
getDisplay()
Returns the Displayable appropriate for this space. |
int |
getNumNeighbors(int x,
int y)
Returns the number of LifeAgents around the x, y coordinate. |
int |
getXSize()
Returns the width of this LifeSpace. |
int |
getYSize()
Returns the height of this LifeSpace. |
boolean |
isEmptyAt(int x,
int y)
Returns true if the cell at the specified coordinates is empty. |
void |
remove(LifeAgent agent)
Removes an agent from this space. |
void |
removeAgentAt(int x,
int y)
Removes the agent at the specified coordinates. |
void |
step(java.util.ArrayList list)
Iterates through each cell, if the cell is empty and has 3 neighbors then new agent there. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LifeSpace(int xSize,
int ySize,
boolean toriodal,
LifeModel model)
| Method Detail |
|---|
public int getXSize()
getXSize in interface Spacepublic int getYSize()
getYSize in interface Spacepublic void remove(LifeAgent agent)
remove in interface Space
public void removeAgentAt(int x,
int y)
removeAgentAt in interface Spacepublic void addAgent(LifeAgent agent)
addAgent in interface Space
public int getNumNeighbors(int x,
int y)
getNumNeighbors in interface Spacepublic Displayable getDisplay()
getDisplay in interface Space
public boolean isEmptyAt(int x,
int y)
isEmptyAt in interface Spacepublic void step(java.util.ArrayList list)
step in interface Space
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||