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

## uchicago.src.repastdemos.life
Class InfiniteLifeSpace

    java.lang.Object
      uchicago.src.repastdemos.life.InfiniteLifeSpace

All Implemented Interfaces:
  Space

    public class InfiniteLifeSpace

extends java.lang.Object
implements Space

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

### MAX

    public static final int MAX

Constructor Detail

### InfiniteLifeSpace

    public 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. The x, y origin of the view window will be roughly the middle of the Space minus one-half of the width / height.

Method Detail

### getXSize

    public int getXSize()

  Returns the width of this InfiniteLifeSpace.

  Specified by:
    `getXSize` in interface `Space`

### getYSize

    public int getYSize()

  Returns the height of this InfiniteLifeSpace.

  Specified by:
    `getYSize` in interface `Space`

### remove

    public void remove(LifeAgent agent)

  Removes an agent from this space. Actual removal is not performed until after all step() methods have completed.

  Specified by:
    `remove` in interface `Space`

### removeAgentAt

    public void removeAgentAt(int x,
                              int y)

  Removes the agent at the specified coordinates. This occurs immediately.

  Specified by:
    `removeAgentAt` in interface `Space`

### addAgent

    public void addAgent(LifeAgent agent)

  Adds the agent at its coordinates.

  Specified by:
    `addAgent` in interface `Space`

### getNumNeighbors

    public int getNumNeighbors(int x,
                               int y)

  Returns the number of LifeAgents around the x, y coordinate. This is a Moore neighborhood.

  Specified by:
    `getNumNeighbors` in interface `Space`

### isEmptyAt

    public boolean isEmptyAt(int x,
                             int y)

  Returns true if the cell at the specified coordinates is empty.

  Specified by:
    `isEmptyAt` in interface `Space`

### getDisplay

    public Displayable getDisplay()

  Returns the Displayable appropriate for this space. In this case, this returns an InfiniteSpaceDisplay.

  Specified by:
    `getDisplay` in interface `Space`

### step

    public 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.

  Specified by:
    `step` in interface `Space`

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