/**
 * A creature that can move and reproduce on a two-dimensional grid.
 *
 * @author Drue Coles
 */
public abstract class Creature {

    protected int age = 0;
    protected int fertility = 0;
    protected int energy;

    /**
     * Constructs a new creature with a given energy level.
     */
    public Creature(int energy) {
        this.energy = energy;
    }

    /**
     * Returns a new creature if fertility level is high enough (null if not).
     */
    abstract Creature reproduce();

    /**
     * Returns this creatures preferred direction to move given a list of the
     * occupants of adjacent cells.
     * 
     * @param neighbors a Direction-indexed list of creatures occupying adjacent 
     * cells (or null for empty cells)
     */
    abstract Direction move(Creature[] neighbors);

    /**
     * Returns true if this creature is dead. Death may be defined for concrete
     * subtypes in terms of age and/or energy.
     */
    abstract boolean isDead();
}