Square

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.

See also:
class Object
trait Matchable
class Any
class Floor
object Wall.type

Value members

Abstract methods

def addRobot(arrivee: RobotBody): Boolean

Adds the given robot to the square, if possible. If there is something already in the square, a collision happens instead.

Adds the given robot to the square, if possible. If there is something already in the square, a collision happens instead.

Value parameters:
arrivee

the robot arriving in the square

Returns:

true if arrivee was successfully placed in the square, false if a collision occurred

def clear(): Unit

Removes any robot from the square (if there was one there to begin with).

Removes any robot from the square (if there was one there to begin with).

Returns true if the square is completely empty (of robots and walls), false otherwise.

Returns true if the square is completely empty (of robots and walls), false otherwise.

Returns true if the square contains a permanent, unpassable barrier, false otherwise.

Returns true if the square contains a permanent, unpassable barrier, false otherwise.

Returns the robot occupying the square, wrapped in an Option, or None, if there is no robot in the square.

Returns the robot occupying the square, wrapped in an Option, or None, if there is no robot in the square.

Concrete methods

Returns true if the square contains any robot or wall, false otherwise.

Returns true if the square contains any robot or wall, false otherwise.