edu.brook.ascape.model
Class HostCell

java.lang.Object
  |
  +--edu.brook.ascape.model.AscapeObject
        |
        +--edu.brook.ascape.model.Agent
              |
              +--edu.brook.ascape.model.Cell
                    |
                    +--edu.brook.ascape.model.HostCell

public class HostCell
extends Cell

An cell capable fo serving as a 'home' for agents. At the moment, only one agent per cell can be hosted.

Since:
1.0
Version:
1.5
See Also:
Serialized Form

Field Summary
protected  HostCell[] availableNeighbors
          Neighbors that are avaalbable, that is, possible to occupy.
static Conditional IS_AVAILABLE
           
static Conditional IS_OCCUPIED
           
protected  CellOccupant[] neighborOccupants
          The collection of neighboring cells.
protected  CellOccupant occupant
          The occupant, if any, of this cell.
 
Fields inherited from class edu.brook.ascape.model.Cell
cellsNear, coordinate, neighbors, thisUpdate
 
Fields inherited from class edu.brook.ascape.model.Agent
DEATH_RULE, deleteMarker, FISSIONING_RULE, FORCE_DIE_RULE, FORCE_FISSION_RULE, FORCE_MOVE_RULE, INITIALIZE_RULE, initialized, ITERATE_AND_UPDATE_RULE, ITERATE_RULE, METABOLISM_RULE, MOVEMENT_RULE, UPDATE_RULE
 
Fields inherited from class edu.brook.ascape.model.AscapeObject
ARBITRARY_SEED, count, name, scape
 
Constructor Summary
HostCell()
           
 
Method Summary
 java.lang.Object clone()
          Clones the host cell, making occupant and neighbors null.
 HostCell findRandomAvailableNeighbor()
          Gets a random neighboring host cell.
 HostCell[] getAvailableNeighbors()
          Returns all neighboring cells which are available for occupation.
 java.awt.Color getColor()
          Returns the default color for this cell (green.) Override to provide another color, or provide a different color feature for your views.
 CellOccupant[] getNearOccupants(int distance, boolean includeSelf)
          Returns all occupants of nearby cells.
 CellOccupant[] getNeighboringOccupants()
          Returns all occupants of neighboring cells.
 CellOccupant getOccupant()
          Return the occupant of this cell, null if no occupant.
 boolean isAvailable()
          Is this cell available (currently unoccupied?)
 boolean isNeighborAvailable()
          Are their any neighboring cells that are available.
 void removeOccupant()
          Evict the supplied occupant.
 void setOccupant(CellOccupant occupant)
          Host the supplied occupant.
 
Methods inherited from class edu.brook.ascape.model.Cell
countNeighbors, countWithin, die, findMaximumWithin, findNearestCell, findNearestCell, findNearestCell, findRandomNeighbor, getCellsNear, getCoordinate, getDistance, getNeighbors, getNeighbors, getNetwork, hasWithin, initialize, isUpdateNeeded, requestUpdate, requestUpdateNext, setCoordinate, setNeighbors, setNetwork, toString
 
Methods inherited from class edu.brook.ascape.model.Agent
death, deathCondition, execute, execute, fission, fissionCondition, fissioning, getColor, getImage, getImage, getIteration, getModel, getRoot, isDelete, isInitialized, iterate, markForDeletion, metabolism, move, movement, movementCondition, play, scapeCreated, update
 
Methods inherited from class edu.brook.ascape.model.AscapeObject
getName, getRandom, getRandomSeed, getScape, randomInRange, randomInRange, randomIs, randomToLimit, reseed, setName, setRandom, setRandomSeed, setScape
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IS_AVAILABLE

public static final Conditional IS_AVAILABLE

IS_OCCUPIED

public static final Conditional IS_OCCUPIED

occupant

protected CellOccupant occupant
The occupant, if any, of this cell.

neighborOccupants

protected CellOccupant[] neighborOccupants
The collection of neighboring cells. Do not assume this to be populated, it is implementation dependent.

availableNeighbors

protected HostCell[] availableNeighbors
Neighbors that are avaalbable, that is, possible to occupy. Again, do not assume this to be populated, it is implementation dependent.
Constructor Detail

HostCell

public HostCell()
Method Detail

isAvailable

public boolean isAvailable()
Is this cell available (currently unoccupied?)
Returns:
true if available, false if not
Overrides:
isAvailable in class Cell

getOccupant

public CellOccupant getOccupant()
Return the occupant of this cell, null if no occupant.
Overrides:
getOccupant in class Cell

isNeighborAvailable

public boolean isNeighborAvailable()
Are their any neighboring cells that are available. return true if adjoing cell is available, false otherwise

findRandomAvailableNeighbor

public HostCell findRandomAvailableNeighbor()
Gets a random neighboring host cell. If none available, returns null.

setOccupant

public void setOccupant(CellOccupant occupant)
Host the supplied occupant. Request a view update.
Overrides:
setOccupant in class Cell

removeOccupant

public void removeOccupant()
Evict the supplied occupant. Request a view update.
Overrides:
removeOccupant in class Cell

getNeighboringOccupants

public CellOccupant[] getNeighboringOccupants()
Returns all occupants of neighboring cells.

getNearOccupants

public CellOccupant[] getNearOccupants(int distance,
                                       boolean includeSelf)
Returns all occupants of nearby cells. Eric's addition for Capitalism game.

getAvailableNeighbors

public HostCell[] getAvailableNeighbors()
Returns all neighboring cells which are available for occupation.

clone

public java.lang.Object clone()
Clones the host cell, making occupant and neighbors null.
Overrides:
clone in class Cell

getColor

public java.awt.Color getColor()
Returns the default color for this cell (green.) Override to provide another color, or provide a different color feature for your views.
Overrides:
getColor in class Agent

(c) 1998-2000 The Brookings Insitution
Webpage