Class: InstructionPointer

InstructionPointer(x, y, direction, program)

An instruction pointer for a ><> program

Constructor

new InstructionPointer(x, y, direction, program)

Creates a new instruction pointer
Parameters:
Name Type Description
x Integer X coordinate to start at
y Integer Y coordinate to start at
direction String Direction to start with
program FishProgram The program this pointer is for
Source:

Members

(static, constant) DIRECTION_EAST :String

Constant for the East direction
Type:
  • String
Source:

(static, constant) DIRECTION_NORTH :String

Constant for the North direction
Type:
  • String
Source:

(static, constant) DIRECTION_SOUTH :String

Constant for the South direction
Type:
  • String
Source:

(static, constant) DIRECTION_WEST :String

Constant for the West direction
Type:
  • String
Source:

(readonly) direction :String

Current direction of the pointer. One of the DIRECTION_* constants
Type:
  • String
Source:

(readonly) x :Integer

Current X coordinate of the pointer
Type:
  • Integer
Source:

(readonly) y :Integer

Current Y coordinate of the pointer
Type:
  • Integer
Source:

Methods

advance()

Advances the pointer one step forward
Source:
Throws:
If the direction is for some reason invalid
Type
Error

changeDirection(newDirection)

Changes the direction of the pointer
Parameters:
Name Type Description
newDirection String The new direction of the pointer. One of the DIRECTION_* constants
Source:
Throws:
If the new direction is invalid
Type
Error

teleport()

Teleports the pointer to a new set of coordinates
Source:
Throws:
If the coordinates are outside the program, or invalid
Type
Error