trait Instruction extends AnyRef
The trait Instruction
represents instructions within RoboSpeak programs.
The program of each Tribe consists of instruction objects; a TribalBot
is able to execute sequences of instructions.
A single Instruction
object represents an instruction for a tribal robot to
do something. By way of example, here are two RoboSpeak instructions in textual
form, each of which can also be represented by an Instruction
object:
turn
goto 1
See the documentation of class Tribe for more details and examples of RoboSpeak.
There are various kinds of instruction objects representing the various kinds of instructions that can appear in RoboSpeak programs. However, all instructions share the common interface described by this trait. Through this interface, instructions can be examined and executed. Each instruction object, irrespective of what is does, provides the following:
- Methods for determining basic information about the instruction: Does executing the instruction end a tribal robot's turn? On which line in a RoboSpeak program does the instruction appear?
- A method for executing the instruction and determining which instruction to execute next.
An instruction object is immutable.
- Alphabetic
- By Inheritance
- Instruction
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def endsTurn: Boolean
Determines if this instruction is of a type which ends the acting robot's turn when executed.
Determines if this instruction is of a type which ends the acting robot's turn when executed. (move does, for instance, while ifempty does not.)
- abstract def execute(actor: TribalBot): Instruction
Causes the given tribal bot to execute the instruction.
Causes the given tribal bot to execute the instruction. What happens as a result depends on the instruction. In the case of an action instruction such as move or hack, the tribal bot does something visible. In the case of a logic instruction such as ifempty, goto or callsub, nothing visible happens immediately, but the bot does something which affects its future behavior.
This method also determines the next instruction that is to be executed by the acting robot next after this instruction is done with. The next instruction may be either the instruction on the following line of the RoboSpeak program (e.g., after a move instruction, or after an ifempty when the square ahead is not empty), or it may be an instruction somewhere else in the program (e.g., after a goto, or after an ifempty when the square ahead is empty).
- actor
a tribal bot whose turn it is and who is to execute the instruction
- returns
the next instruction that is to be executed by the actor after this one (possibly only during a future turn)
- abstract def lineNumber: Int
Returns the number of the line (1 or higher) that the instruction appears on the RoboSpeak program that it is a part of.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString: String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
- Deprecated
(Since version ) see corresponding Javadoc for more information.