org.holtz.zoe
Enum Operator

java.lang.Object
  extended by java.lang.Enum<Operator>
      extended by org.holtz.zoe.Operator
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Operator>

public enum Operator
extends java.lang.Enum<Operator>

The verb of an Operation in a Zoel program.

Author:
Brian Holtz

Enum Constant Summary
AbsoluteVal
           
Add
           
And
           
Barf
          Barf up some energy to leave at the current location.
Bite
          Bite energy from the nearest ZObject.
Call
          Branch to the indicated Statement, and return at the end of its StatementList or when it Returns.
Divide
           
Else
          If stack top is false (zero/empty), evaluate arg.
Equals
           
Feel
          Sense the nearest ZObject within MaxBiteRange and mass > InvisibilityThreshold * own mass.
Get
          Copy a heap value to the stack, where arg is the map key.
GreaterThan
           
IfThen
          If stack top is true (nonzero/nonempty), evaluate arg.
LessThan
           
Look
          Sense the nearest ZObject within MaxLookRange and mass > InvisibilityThreshold * own mass.
Mate
          Exchange genes with the nearest visible bug that is within Feel range.
Modulus
           
Mood
          Copy the arg (or stack top) to the Mood register.
Move
          Move forward along $Heading.
Multiply
           
Negate
           
Not
           
Or
           
Poke
          Set the top of the stack.
Pop
          Pop the top off the stack.
Pray
          Send a message to the gods.
Push
          Push the arg onto the stack.
Random
           
Return
          Return to the Statement after the corresponding Call, or break from the enclosing While.
Set
          Set a mapping in the heap, where arg is the map key and the stack top is the value.
Spawn
          Attempt to spawn a child using only available strength.
Split
          Attempt to split into a parent and child of equal size and strength.
Subtract
           
Turn
          Turn to a different direction in order to Move that way.
While
          While stack top is true (nonzero/nonempty), evaluate arg.
 
Method Summary
static Operator fromString(java.lang.String str)
           
static Operator pseudoRandom(java.util.Random random)
           
static Operator random(java.util.Random random)
           
static Operator valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static Operator[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 ZoelVM.Turn whetherTurnContinues()
           
 
Methods inherited from class java.lang.Enum
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

Move

public static final Operator Move
Move forward along $Heading. If no arg, arg = 1.0. If 0 <= arg <= 2, arg is speed. Energy cost is proportional to speed ^ 2.


Turn

public static final Operator Turn
Turn to a different direction in order to Move that way. Arg can be $Toward or $Away from last-sensed ZObject. If no arg, arg is $Toward. $$Bearing is (other.heading - this.heading), so Turn $$Bearing follows other. If -2 PI <= arg <= 2 PI, arg is radians. Else, if -180 <= arg <= 180, arg is degrees.


Bite

public static final Operator Bite
Bite energy from the nearest ZObject.


Barf

public static final Operator Barf
Barf up some energy to leave at the current location. If no arg, arg = 1.0. If 0 <= arg <= 1.0, arg is fraction of current bite size.


Spawn

public static final Operator Spawn
Attempt to spawn a child using only available strength. A child is only created if
  1. she would have at least the mass-energy of a max-strength min-size bug, and the mother would be left with strength >= 0.


Split

public static final Operator Split
Attempt to split into a parent and child of equal size and strength. A child is only created if she would have at least the mass-energy of a max-strength min-size bug. Because bugs are ignored by their own Feel/Look/Bite operations, mother and child are invisible to each other's Feel/Look/Bite operations for a brief period following a Split.


Mate

public static final Operator Mate
Exchange genes with the nearest visible bug that is within Feel range. A new species is created by combining half the toplevel StatementList of each bug. The next child of each bug will be of this species.


Feel

public static final Operator Feel
Sense the nearest ZObject within MaxBiteRange and mass > InvisibilityThreshold * own mass. Sets $Gaze if an object was sensed, and sets stack top to whether an object was sensed.


Look

public static final Operator Look
Sense the nearest ZObject within MaxLookRange and mass > InvisibilityThreshold * own mass. Sets $Gaze if an object was sensed, and sets stack top to whether an object was sensed.


Mood

public static final Operator Mood
Copy the arg (or stack top) to the Mood register.


Pray

public static final Operator Pray
Send a message to the gods. Pushes any arg, then prints popped stack top on System.out.


Call

public static final Operator Call
Branch to the indicated Statement, and return at the end of its StatementList or when it Returns. Arg is the label or id of the Statement to which to branch.


Return

public static final Operator Return
Return to the Statement after the corresponding Call, or break from the enclosing While.


IfThen

public static final Operator IfThen
If stack top is true (nonzero/nonempty), evaluate arg. If stack top is not true and the next Statement is Else, then skips the Else.


Else

public static final Operator Else
If stack top is false (zero/empty), evaluate arg.


While

public static final Operator While
While stack top is true (nonzero/nonempty), evaluate arg.


Push

public static final Operator Push
Push the arg onto the stack. The stack size is limited to a function of bug age, so the deepest stack element might be discarded.


Pop

public static final Operator Pop
Pop the top off the stack.


Poke

public static final Operator Poke
Set the top of the stack.


Set

public static final Operator Set
Set a mapping in the heap, where arg is the map key and the stack top is the value. The heap size is limited to a function of bug age, so the oldest stack element might be discarded.


Get

public static final Operator Get
Copy a heap value to the stack, where arg is the map key. If the key is not found, copies 0.


And

public static final Operator And

Or

public static final Operator Or

Not

public static final Operator Not

Negate

public static final Operator Negate

Equals

public static final Operator Equals

LessThan

public static final Operator LessThan

GreaterThan

public static final Operator GreaterThan

Random

public static final Operator Random

Add

public static final Operator Add

Subtract

public static final Operator Subtract

Multiply

public static final Operator Multiply

Divide

public static final Operator Divide

Modulus

public static final Operator Modulus

AbsoluteVal

public static final Operator AbsoluteVal
Method Detail

values

public static Operator[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (Operator c : Operator.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static Operator valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

whetherTurnContinues

public ZoelVM.Turn whetherTurnContinues()

fromString

public static Operator fromString(java.lang.String str)

random

public static Operator random(java.util.Random random)

pseudoRandom

public static Operator pseudoRandom(java.util.Random random)