morey.spore
Class Flip

java.lang.Object
  |
  +--morey.spore.SporeAction
        |
        +--morey.spore.Flip

public class Flip
extends SporeAction
implements java.lang.Cloneable

The flip occurs off the side that the spore is heading. It is like putting a mirror along the side that the spore is heading then replacing the spore with its mirror image. The mirror image concept is important to have since The odd side polygons have an interesting way of flipping twice. When going in a straight line the new headings are not clear for a odd side polygon. Arbitrarily, we favour the a slightly right handed world. But after a flip this favouring is now a slightly left handed world. This allows for odd sided polygons to move in a straight line easily. For instance,

pent 5 10 flip |

moves first slightly right then slightly left then back again slightly etc. This cause an over all straight line. This is a bit subtle since all new odd-sided spores start with a right leaning.

A flip could cause a collision and demise of the spore.

The execution time is related to the area of the spore (an arbitrary unit that the others will be scaled against). The complexity of this SporeAction is moderate (and also a unit value that the others will be scaled).

Here is a link to the source code

See Also:
RPolygon.flip(), RPolygon.right(), Left, Right, Type, Claim, Spawn

Field Summary
protected static int COMPLEXITY
           
protected static double EXECUTE
           
 
Fields inherited from class morey.spore.SporeAction
NO_COMPLEXITY
 
Constructor Summary
Flip()
          construct a simple flip.
 
Method Summary
 boolean executeAction(Spore s, Processor cpu)
          flip the spore
 double getExecutionTime(Spore s, Processor cpu)
          gets up the time of execution for the next action
 java.lang.String toString()
          Gives a String representation of this
 
Methods inherited from class morey.spore.SporeAction
addSpore, addSporeCommands, parseCommand, parseSpore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXECUTE

protected static final double EXECUTE

COMPLEXITY

protected static final int COMPLEXITY
Constructor Detail

Flip

public Flip()
construct a simple flip.
Method Detail

getExecutionTime

public double getExecutionTime(Spore s,
                               Processor cpu)
gets up the time of execution for the next action
Overrides:
getExecutionTime in class SporeAction
Parameters:
s - the spore wanting to execute the action
cpu - that executes this action (and required info...)
Returns:
the time of execution

executeAction

public boolean executeAction(Spore s,
                             Processor cpu)
flip the spore
Overrides:
executeAction in class SporeAction
Returns:
true if it doesn't collide

toString

public java.lang.String toString()
Gives a String representation of this
Overrides:
toString in class java.lang.Object