Class Instruction

java.lang.Object
  extended by Instruction

public class Instruction
extends Object

This class represents one Darwin instruction. Instructions contain two parts: an opcode and an address. For instructions that do not perform jumps (hop, left, right, infect), the address part is not used. The fill instruction set is the following:

   hop
   left
   right
   infect
   ifempty
   ifwall
   ifsame
   ifenemy
   ifrandom
   go
 
The following instructions require a target address to jump to:
ifempty, ifwall, ifsame, ifenemy, ifrandom, go


Field Summary
static int GO
          opcode for the go instruction
static int HOP
          opcode for the hop instruction
static int IFEMPTY
          opcode for the ifempty instruction
static int IFENEMY
          opcode for the ifenemy instruction
static int IFRANDOM
          opcode for the ifrandom instruction
static int IFSAME
          opcode for the ifsame instruction
static int IFWALL
          opcode for the ifwall instruction
static int INFECT
          opcode for the infect instruction
static int LEFT
          opcode for the left instruction
static int RIGHT
          opcode for the right instruction
 
Constructor Summary
Instruction(int opcode, int address)
          Creates a new instruction.
 
Method Summary
 int getAddress()
          Returns the addrss
 int getOpcode()
          Returns the opcode
 String toString()
          Returns a printable representation of an Instruction
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HOP

public static final int HOP
opcode for the hop instruction

See Also:
Constant Field Values

LEFT

public static final int LEFT
opcode for the left instruction

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
opcode for the right instruction

See Also:
Constant Field Values

INFECT

public static final int INFECT
opcode for the infect instruction

See Also:
Constant Field Values

IFEMPTY

public static final int IFEMPTY
opcode for the ifempty instruction

See Also:
Constant Field Values

IFWALL

public static final int IFWALL
opcode for the ifwall instruction

See Also:
Constant Field Values

IFSAME

public static final int IFSAME
opcode for the ifsame instruction

See Also:
Constant Field Values

IFENEMY

public static final int IFENEMY
opcode for the ifenemy instruction

See Also:
Constant Field Values

IFRANDOM

public static final int IFRANDOM
opcode for the ifrandom instruction

See Also:
Constant Field Values

GO

public static final int GO
opcode for the go instruction

See Also:
Constant Field Values
Constructor Detail

Instruction

public Instruction(int opcode,
                   int address)
Creates a new instruction. address is the target of the operation, if one is needed. Otherwise it is not used.

Method Detail

getOpcode

public int getOpcode()
Returns the opcode


getAddress

public int getAddress()
Returns the addrss


toString

public String toString()
Returns a printable representation of an Instruction

Overrides:
toString in class Object