sim
Interface Critter

All Known Implementing Classes:
Grass, Insect

public interface Critter

This interface describes the methods that a MatrixModel creature must implement.


Method Summary
 CritterInfo getCritterInfo()
          This method returns the CritterInfo object that is storing information about this Critter.
 CritterFace getFace(int w, int h)
          This method returns a CritterFace (a displayable collection of Shapes) that can be used to represent this Critter in a MatrixView.
 Critter reproduce()
          This method creates another object of the same type as this Critter.
 int[] selectNextCell(MatrixModel model, int[] curLoc)
          This method implements the logic of this Critter that decides where it wants to move to next.
 

Method Detail

selectNextCell

public int[] selectNextCell(MatrixModel model,
                            int[] curLoc)
This method implements the logic of this Critter that decides where it wants to move to next. The MatrixModel is provided so that this Critter can ask the model about its neighbors, if it wants to use that information in making the decision.

Parameters:
model - the MatrixModel that this Critter inhabits
curLoc - a 2-element int array containing the current cell location of this Critter. The row address is in element [0] and the column address is in element [1].
Returns:
a 2-element int array to hold the cell location this Critter would like to move to. The row address is in element [0] and the column address is in element [1].
See Also:
MatrixModel.getCritter(int[])

getFace

public CritterFace getFace(int w,
                           int h)
This method returns a CritterFace (a displayable collection of Shapes) that can be used to represent this Critter in a MatrixView. The width and height of the available space are provided so that the Shapes can be scaled to fit the space. It's also possible to create a different face depending on the amount of space available. For example, a very small space might just get a dot, but a larger space could get a small drawing.

Parameters:
w - the width in pixels of the space the Shapes will occupy on screen
h - the height in pixels of the space the Shapes will occupy on screen
Returns:
the CritterFace to display for this Critter

getCritterInfo

public CritterInfo getCritterInfo()
This method returns the CritterInfo object that is storing information about this Critter.

Returns:
an object that implements the CritterInfo interface and holds current information about the Critter

reproduce

public Critter reproduce()
This method creates another object of the same type as this Critter.

Returns:
a new Critter object of the same type as this Critter