com.epochx.representation.action
Class Seq2Function

java.lang.Object
  extended by com.epochx.representation.Node<TYPE>
      extended by com.epochx.representation.FunctionNode<Action>
          extended by com.epochx.representation.action.Seq2Function
All Implemented Interfaces:
java.lang.Cloneable

public class Seq2Function
extends FunctionNode<Action>

A FunctionNode which provides the facility to sequence two instructions - which may be other functions or terminal nodes with actions.


Constructor Summary
Seq2Function()
          Construct a Seq2Function with no children.
Seq2Function(Node<Action> child1, Node<Action> child2)
          Construct a Seq2Function with two children.
 
Method Summary
 Action evaluate()
          Evaluating a Seq2Function involves evaluating each of the children in sequence - the first child node, followed by the second child node.
 java.lang.String getFunctionName()
          Get the unique name that identifies this function.
 
Methods inherited from class com.epochx.representation.FunctionNode
equals, toString
 
Methods inherited from class com.epochx.representation.Node
clone, getArity, getChild, getChildren, getDepth, getFunctionNodes, getLength, getNodesAtDepth, getNoDistinctFunctions, getNoDistinctTerminals, getNoFunctions, getNoTerminals, getNthNode, getTerminalNodes, hashCode, setChild, setChildren, setNthNode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Seq2Function

public Seq2Function()
Construct a Seq2Function with no children.


Seq2Function

public Seq2Function(Node<Action> child1,
                    Node<Action> child2)
Construct a Seq2Function with two children. When evaluated, the first child node will be taken first and evaluated, then the second child node will be taken and evaluated. As such they will have been executed in sequence.

Parameters:
child1 - The first child node to be executed first in sequence.
child2 - The second child node to be executed second in sequence.
Method Detail

evaluate

public Action evaluate()
Evaluating a Seq2Function involves evaluating each of the children in sequence - the first child node, followed by the second child node.

Each of the children will thus have been evaluated (triggering execution of actions at the TerminalNodes) and then this method which must return an Action, returns Action.DO_NOTHING which any functions higher up in the program tree will execute, but with no effect.

Specified by:
evaluate in class Node<Action>
Returns:
The result of evaluating the candidate program.

getFunctionName

public java.lang.String getFunctionName()
Get the unique name that identifies this function.

Specified by:
getFunctionName in class FunctionNode<Action>
Returns:
the unique name for the Seq2Function which is SEQ2.