o1.robots

package o1.robots

Type members

Classlikes

class Floor extends Square

The class Floor represents squares that robots can successfully occupy and move through. On creation, a floor square is always empty, but this changes if a robot arrives.

The class Floor represents squares that robots can successfully occupy and move through. On creation, a floor square is always empty, but this changes if a robot arrives.

class Lovebot(name: String, body: RobotBody, val beloved: RobotBody) extends RobotBrain

The class Lovebot represents the “brains” of robots which have another robot as their “beloved”. A lovebot tries to home in on its beloved.

The class Lovebot represents the “brains” of robots which have another robot as their “beloved”. A lovebot tries to home in on its beloved.

Value parameters:
beloved

another robot that the lovebot targets

body

the robot body whose actions the lovebot brain will control

name

the name of the lovebot

class Nosebot(name: String, body: RobotBody) extends RobotBrain

The class Nosebot represents the “brains” of robots that move in the direction their nose points, in straight lines, only turning when they have to. They always turn right.

The class Nosebot represents the “brains” of robots that move in the direction their nose points, in straight lines, only turning when they have to. They always turn right.

Value parameters:
body

the robot body whose actions the nosebot brain will control

name

the name of the nosebot

class Psychobot(name: String, body: RobotBody) extends RobotBrain

The class Psychobot represents the “brains” of robots which stand still until they see another unbroken robot. When this happens, they ram the victim with incredible speed.

The class Psychobot represents the “brains” of robots which stand still until they see another unbroken robot. When this happens, they ram the victim with incredible speed.

Value parameters:
body

the robot body whose actions the psychobot brain will control

name

the name of the psychobot

class RobotBody(val world: RobotWorld, initialLocation: GridPos, initialFacing: CompassDir)

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.

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

Value parameters:
initialFacing

the direction the robot initially faces in

initialLocation

the initial location of the robot in its world

world

the world inhabited by the robot

See also:
trait RobotBrain(initialName: String, val body: RobotBody)

The trait RobotBrain represents the “brains” (or artificial “intelligence”) of virtual robots that inhabit two dimensional grid worlds. A robot brain is equipped with an algorithm for determining what a robot should do during its turn in a robot simulation. In other words, a robot brain is capable of controlling the actions of a robot body.

The trait RobotBrain represents the “brains” (or artificial “intelligence”) of virtual robots that inhabit two dimensional grid worlds. A robot brain is equipped with an algorithm for determining what a robot should do during its turn in a robot simulation. In other words, a robot brain is capable of controlling the actions of a robot body.

Concrete classes that extend this trait need to provide implementations for the abstract moveBody method; each such concrete class can represent a new kind of robot behavior. Overriding the mayAdvance method may also be necessary.

Value parameters:
body

the body the robot brain will control

initialName

the name of the robot

class RobotWorld(floorWidth: Int, floorHeight: Int) extends Grid[Square]

An instance of the class RobotWorld represents a mutable, two-dimensional world that can be inhabited by virtual robots. This kind of “robot world” is a Grid whose elements are Square objects.

An instance of the class RobotWorld represents a mutable, two-dimensional world that can be inhabited by virtual robots. This kind of “robot world” is a Grid whose elements are Square objects.

Robots — RobotBody objects — can be added to the robot world, and the robot world object maintains a listing of the added robots. It uses this list to have the robots take their turns in a round-robin fashion.

Apart from robots, a robot world can also contain walls. All robot worlds are bounded by walls on all sides: all the edge squares of all robot worlds are always unpassable by robots. Wall squares may also be added at other locations within a world.

Value parameters:
floorHeight

the height of the robot world, in squares, in addition to the walls at the top and at the bottom. The total height of the grid will be two plus this number.

floorWidth

the width of the robot world, in squares, in addition to the walls on both sides. The total width of the grid will be two plus this number.

See also:
class Spinbot(name: String, body: RobotBody) extends RobotBrain

The class Spinbot represents the “brains” of extremely simple robots that simply spin clockwise and never change location.

The class Spinbot represents the “brains” of extremely simple robots that simply spin clockwise and never change location.

Value parameters:
body

the robot body whose actions the spinbot brain will control

name

the name of the spinbot

trait Square

The trait Square represents squares in a robot world, as an abstract concept. A square object is potentially mutable: its state can change as robots enter and exit it. Two concrete kinds of squares have been implemented: Floors and Walls.

The trait Square represents squares in a robot world, as an abstract concept. A square object is potentially mutable: its state can change as robots enter and exit it. Two concrete kinds of squares have been implemented: Floors and Walls.

See also:
class Staggerbot(name: String, body: RobotBody, randomSeed: Int) extends RobotBrain

The class Staggerbot represents the “brains” of robots whose algorithms are not sophisticated enough to beat a game of Viinaharava. These robots stagger from place to place harum-scarum, relying on a (pseudo)random number generator.

The class Staggerbot represents the “brains” of robots whose algorithms are not sophisticated enough to beat a game of Viinaharava. These robots stagger from place to place harum-scarum, relying on a (pseudo)random number generator.

Value parameters:
body

the unlucky robot body whose actions the staggerbot brain will control

name

the name of the staggerbot

randomSeed

the seed that feeds the random generator that guides the bot

object Wall extends Square

The singleton object Wall represents walls, that is, squares that constitute unpassable barriers for robots. A robot can never be in the same location with a wall.

The singleton object Wall represents walls, that is, squares that constitute unpassable barriers for robots. A robot can never be in the same location with a wall.

Since all wall locations in all robot worlds are alike and immutable, it is enough to have a single Wall object that can be placed anywhere in any robot world. There is no need for separate instances for each wall square.