edu.brook.ascape.model
Class CellOccupant

java.lang.Object
  |
  +--edu.brook.ascape.model.AscapeObject
        |
        +--edu.brook.ascape.model.Agent
              |
              +--edu.brook.ascape.model.Cell
                    |
                    +--edu.brook.ascape.model.CellOccupant
Direct Known Subclasses:
Scape

public class CellOccupant
extends Cell

An occupant of a cell within a lattice.

Since:
1.0
Version:
1.5
See Also:
Serialized Form

Field Summary
static Rule MOVE_RANDOM_LOCATION_RULE
          A rule causing the taget agent to move to a random location.
static Rule PLAY_HOST_RULE
          An rule causing the target agent to interact with each of its neighbors as specified by the Agent.play() method.
static Rule PLAY_NEIGHBORS_RULE
          An rule causing the target agent to interact with each of its neighbors as specified by the Agent.play() method.
static Rule PLAY_OTHER
          An rule causing the target agent to interact with another agent in its scape using the Agent.play() method.
static Rule RANDOM_WALK_AVAILABLE_RULE
          A rule causing the taget agent to take a random walk.
static Rule RANDOM_WALK_RULE
          A rule causing the taget agent to take a random walk.
 
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
CellOccupant()
           
 
Method Summary
 java.lang.Object clone()
          Clone this occupant, making host cell and coordinate null, since for a base cell occupant it is illegal for more than one cell to occupy the same location.
 void die()
          Removes the agent from play, causing it to vacate its host cell.
 Cell[] getAvailableNeighboringCells()
          Returns unoccupied cells neighboring this cell's location on the host cell's lattice.
 Cell[] getCellsNearOnHost(int distance, boolean includeSelf)
          Return other cell occupants near host cell on host scape.
 HostCell getHostCell()
          Returns the cell that this cell occupies in the host cell's lattice.
 ScapeGraph getHostScape()
          Returns the lattice that hosts this cell.
 Cell[] getNeighborsOnHost()
          Overides the getNeighbors method to return the cell's occupants neighboring this cell's location on its host cell's lattice.
 void leave()
          Removes this cell from the current host cell.
 void moveAway(HostCell targetCell)
          Move one step toward the occupant of the supplied host cell.
 void moveTo(HostCell hostCell)
          Assigns this cell as the occupant of the supplied host cell.
 void moveToRandomLocation()
          Moves this cell to a random unoccupied location on the host scape.
 void moveToward(HostCell targetCell)
          Move one step toward the occupant of the supplied host cell.
 void randomWalk()
          Picks a random neighboring location on the host cell's lattice.
 void randomWalkAvailable()
          Picks a random available neighboring location on the host cell's lattice.
 void setHostScape(ScapeGraph hostScape)
          Sets the lattice that hosts this cell.
 
Methods inherited from class edu.brook.ascape.model.Cell
countNeighbors, countWithin, findMaximumWithin, findNearestCell, findNearestCell, findNearestCell, findRandomNeighbor, getCellsNear, getCoordinate, getDistance, getNeighbors, getNeighbors, getNetwork, getOccupant, hasWithin, initialize, isAvailable, isUpdateNeeded, removeOccupant, requestUpdate, requestUpdateNext, setCoordinate, setNeighbors, setNetwork, setOccupant, toString
 
Methods inherited from class edu.brook.ascape.model.Agent
death, deathCondition, execute, execute, fission, fissionCondition, fissioning, getColor, 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

MOVE_RANDOM_LOCATION_RULE

public static final Rule MOVE_RANDOM_LOCATION_RULE
A rule causing the taget agent to move to a random location.

PLAY_HOST_RULE

public static final Rule PLAY_HOST_RULE
An rule causing the target agent to interact with each of its neighbors as specified by the Agent.play() method.

PLAY_NEIGHBORS_RULE

public static final Rule PLAY_NEIGHBORS_RULE
An rule causing the target agent to interact with each of its neighbors as specified by the Agent.play() method.

PLAY_OTHER

public static final Rule PLAY_OTHER
An rule causing the target agent to interact with another agent in its scape using the Agent.play() method.

RANDOM_WALK_RULE

public static final Rule RANDOM_WALK_RULE
A rule causing the taget agent to take a random walk. The agent attempts to take a random step in a random direction. If the cell at the random location already has an occupant, nothing happens. Note the difference between this rule and RANDOM_WALK_AVAILABLE_RULE.

RANDOM_WALK_AVAILABLE_RULE

public static final Rule RANDOM_WALK_AVAILABLE_RULE
A rule causing the taget agent to take a random walk. The agent takes a step in a random direction out of any open directions, that is, into a random unoccupied neighboring cell. If no neighboring cells are unoccupied, nothing happens. Note the difference between this rule and RANDOM_WALK_RULE.
Constructor Detail

CellOccupant

public CellOccupant()
Method Detail

leave

public void leave()
Removes this cell from the current host cell.

moveTo

public void moveTo(HostCell hostCell)
Assigns this cell as the occupant of the supplied host cell.
Parameters:
hostCell - the host to assign this cell to

moveToward

public void moveToward(HostCell targetCell)
Move one step toward the occupant of the supplied host cell. Warning: temporary, only works for cells on 2D lattices now.
Parameters:
hostCell - the host to move towards

moveAway

public void moveAway(HostCell targetCell)
Move one step toward the occupant of the supplied host cell. Warning: temporary, only works for cells on 2D lattices now.
Parameters:
hostCell - the host to move towards

moveToRandomLocation

public void moveToRandomLocation()
Moves this cell to a random unoccupied location on the host scape.

die

public void die()
Removes the agent from play, causing it to vacate its host cell.
Overrides:
die in class Cell

getHostCell

public HostCell getHostCell()
Returns the cell that this cell occupies in the host cell's lattice.

getHostScape

public ScapeGraph getHostScape()
Returns the lattice that hosts this cell.

setHostScape

public void setHostScape(ScapeGraph hostScape)
Sets the lattice that hosts this cell.

getNeighborsOnHost

public Cell[] getNeighborsOnHost()
Overides the getNeighbors method to return the cell's occupants neighboring this cell's location on its host cell's lattice.

getCellsNearOnHost

public Cell[] getCellsNearOnHost(int distance,
                                 boolean includeSelf)
Return other cell occupants near host cell on host scape. Eric's addition, to make his life easier in game of Capitalism

getAvailableNeighboringCells

public Cell[] getAvailableNeighboringCells()
Returns unoccupied cells neighboring this cell's location on the host cell's lattice.

randomWalk

public void randomWalk()
Picks a random neighboring location on the host cell's lattice. If that location is unoccupied, moves this agent to it. Note the distinction between this method and randomWalkAvailable. In this case, a random neighboring cell is slected. If, and only if, that cell is unoccupied, does the agent move to it. This means, for instance, that a neighboring cell might be available but the cell occupant migh select an occupied cell and thus not move.
See Also:
randomWalkAvailable

randomWalkAvailable

public void randomWalkAvailable()
Picks a random available neighboring location on the host cell's lattice. If no locations are available, stays put. Note the distinction between this method and randomWalk. In this case, all available neigbors are first found, and then one of those cells is randomly selected and moved to. This means that if there is even one unoccpied cell available, the cell occupant will move to it.
See Also:
randomWalk

clone

public java.lang.Object clone()
Clone this occupant, making host cell and coordinate null, since for a base cell occupant it is illegal for more than one cell to occupy the same location.
Overrides:
clone in class Cell

(c) 1998-2000 The Brookings Insitution
Webpage