Packages

c

o1.robots

RobotBody

class RobotBody extends AnyRef

The class RobotBody represents virtual robots (or "bots") which inhabit two-dimensional grid worlds. More specifically, each instance of the class represents a "robot body" (or "chassis" or "hardware") and basic functionality of such a robot. Each "robot body" is associated with a "robot brain" that controls the body and determines what functionality is activated and when.

A robot is equipped with the various capabilities:

- It can sense its own surroundings (location, facing, the world that it is in).

- It can spin around in any one of the four main compass directions.

- It can move into the next square in a given direction.

- It can sense whether it is broken or not, and whether it is "stuck" in a square between four walls.

When a robot's takeTurn method is called, it uses its "brain" to figure out what to do (move, turn about, etc.). Robots with different kinds of brains behave differently.

See also

RobotWorld

RobotBrain

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. RobotBody
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new RobotBody(world: RobotWorld, initialLocation: o1.GridPos, initialFacing: o1.CompassDir)

    world

    the world inhabited by the robot

    initialLocation

    the initial location of the robot in its world

    initialFacing

    the direction the robot initially faces in

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. var brain: Option[RobotBrain]

    the robot's brain (if it has one)

  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  7. def destroy(): Unit

    Causes the robot to malfunction (typically as the result of a collision).

    Causes the robot to malfunction (typically as the result of a collision). A broken robot does not do anything during its turns.

    See also

    fix

  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  10. def facing: o1.CompassDir

    Returns the direction the robot is currently facing in.

  11. def fix(): Unit

    Repairs a broken robot.

    Repairs a broken robot. The robot can now start taking its turns normally.

    See also

    destroy

  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. def isIntact: Boolean

    Determines whether the robot is currently intact or not.

    Determines whether the robot is currently intact or not. A robot is intact unless it has been broken with the destroy method and not fixed since.

  16. def location: o1.GridPos

    Returns the coordinates that indicate the robot's current location in the robot world.

  17. def locationSquare: Square

    Returns the square the robot is currently in.

  18. def moveTowards(direction: o1.CompassDir): Boolean

    Relocates the robot within its current world to the square next to the robot's current location, in the given direction.

    Relocates the robot within its current world to the square next to the robot's current location, in the given direction. The direction does not necessarily have to be the same one that the robot is originally facing in.

    This method turns the robot to face in the direction it moves in.

    Two robots can never be in the same square; neither can a robot and a wall. If the robot's would-be location is not empty, a collision occurs instead and the robot does not change locations (but still turns to face whatever it collided with).

    If the moving robot collides with a wall, the robot itself breaks. If a moving robot collides with another robot, the other robot breaks and the moving robot stays intact.

    returns

    true if the robot successfully changed locations, false if it did not (even if it changed facing)

  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. def neighboringSquare(direction: o1.CompassDir): Square

    Returns a square that neighbors the robot's current location in the given direction.

  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  23. def spinClockwise(): Unit

    Turns the robot 90 degrees clockwise.

  24. def spinTowards(newFacing: o1.CompassDir): Unit

    Turns the robot to face in the specified direction.

  25. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  26. def takeTurn(): Unit

    Gives the robot a turn to act.

    Gives the robot a turn to act.

    A broken robot does nothing during its turn; a brainless robot likewise does nothing. An intact robot with a brain consults its brain to find out what to do with its turn. It does that by calling the brain's controlTurn method.

    See also

    RobotBrain.controlTurn

  27. def toString: String
    Definition Classes
    AnyRef → Any
  28. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  29. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  30. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  31. val world: RobotWorld

Deprecated Value Members

  1. 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.

Inherited from AnyRef

Inherited from Any

Ungrouped