morey.spore
Class Spore

java.lang.Object
  |
  +--morey.spore.Spore

public class Spore
extends java.lang.Object
implements Comparable

A Spore is cell that can move, claim territory, and spawn off more spores. The main features are:

The processor manages the spore's actions through setCurrentAction and executeCurrentAction. The compareTo allows for the spores to be put into a heap in the so that actions can be done in order.

Here is a link to the source code

See Also:
Processor, RPolygon, SporeAction, Link

Field Summary
protected  java.util.Stack commands
          the commands for the life cycle of the spore
protected  int complexity
          the complexity of its life cycle
protected static int DONE
           
protected  Link link
          the Link to the world (to test collisions)
protected  double nextTime
          the time till the next command
protected  RPolygon polygon
          the physical body of the spore
protected  int sides
          the number of sides of its polygon
 
Constructor Summary
Spore(java.util.Stack s, double[] one, double[] two, int type)
          construct a spore
Spore(java.util.Stack s, int complexity)
          construct a spore ....
 
Method Summary
 int compareTo(java.lang.Object other)
          compares the nextTimes of the spores.
 boolean executeCurrentAction(Processor cpu)
          executes the current action
 void setCurrentAction(Processor cpu)
          sets up the current action.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DONE

protected static final int DONE

polygon

protected RPolygon polygon
the physical body of the spore

nextTime

protected double nextTime
the time till the next command

commands

protected java.util.Stack commands
the commands for the life cycle of the spore

link

protected Link link
the Link to the world (to test collisions)

complexity

protected int complexity
the complexity of its life cycle

sides

protected int sides
the number of sides of its polygon
Constructor Detail

Spore

public Spore(java.util.Stack s,
             double[] one,
             double[] two,
             int type)
construct a spore
Parameters:
s - - a stack of instructions for the spore to perform
one - - the coodinate for the first point on RPolygon
two - - the coodinate for the second point on RPolygon
type - - which group the Spore belongs

Spore

public Spore(java.util.Stack s,
             int complexity)
construct a spore .... for what?
Parameters:
s - - a stack of instructions for the spore to perform
complexity - - the complexity of the spore
Method Detail

setCurrentAction

public void setCurrentAction(Processor cpu)
sets up the current action. This sets the time that the spore's next action will take place. The next command on the commands stack is insured to be a true action not a Repeater or a Sequence after this method.
Parameters:
cpu - the processor that is controling the spores actions
Returns:
false if the spore doesn't is dead and true otherwise

executeCurrentAction

public boolean executeCurrentAction(Processor cpu)
executes the current action
Parameters:
cpu - the processor that is controling the spores actions
Returns:
false if the spore doesn't is dead and true otherwise

compareTo

public int compareTo(java.lang.Object other)
compares the nextTimes of the spores. Used for sequencing the spores actions.
Specified by:
compareTo in interface Comparable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object