|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.repastdemos.life.InfiniteLifeSpace
public class InfiniteLifeSpace
An infinte grid space for LifeAgents. This is "infinite" in that it is a really large sparse matrix. InfiniteSpaceDisplay is a kind of window into this grid. 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.
| Field Summary | |
|---|---|
static int |
MAX
|
| Constructor Summary | |
|---|---|
InfiniteLifeSpace(LifeModel model,
int viewWidth,
int viewHeight)
Creates this InfiniteLifeSpace. viewWidth and viewHeight will be the width of the initial view window into this space. |
|
| 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 InfiniteLifeSpace. |
int |
getYSize()
Returns the height of this InfiniteLifeSpace. |
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)
Checks if any empty space is surrounded by 3 and only 3 LifeAgents, and if so then creates new LifeAgent there. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX
| Constructor Detail |
|---|
public InfiniteLifeSpace(LifeModel model,
int viewWidth,
int viewHeight)
| 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 Space
public boolean isEmptyAt(int x,
int y)
isEmptyAt in interface Spacepublic Displayable getDisplay()
getDisplay 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 | |||||||||