o1.grid
Members list
Type members
Classlikes
The type CompassDir
represents the cardinal compass directions in a gridlike coordinate system. There are exactly four instances of this type: North
, East
, South
and West
, which are also defined in this package.
The type CompassDir
represents the cardinal compass directions in a gridlike coordinate system. There are exactly four instances of this type: North
, East
, South
and West
, which are also defined in this package.
All the CompassDir
objects are immutable.
This type and its instances have aliases in the toplevel package o1, so they are accessible to students simply via import o1.*
.
Parameters
 xStep

the change in x coordinate if one moves one step in this direction. For instance,
West
has anxStep
of 1 andNorth
has anxStep
of 0.  yStep

the change in y coordinate if one moves one step in this direction. For instance,
North
has anyStep
of 1 andWest
has anyStep
of 0.
Attributes
 See also
 Companion
 object
 Supertypes
This companion object of type CompassDir
provides a selection of related constants and utility methods.
This companion object of type CompassDir
provides a selection of related constants and utility methods.
This object has an alias in the toplevel package o1, so it’s accessible to students simply via import o1.*
.
Attributes
 Companion
 enum
 Supertypes
 Self type

CompassDir.type
The trait Grid
represents rectangular grids that contain elements of a particular kind. Each element in a grid is located at a unique pair of coordinates, represented as a GridPos.
The trait Grid
represents rectangular grids that contain elements of a particular kind. Each element in a grid is located at a unique pair of coordinates, represented as a GridPos.
X coordinates run from 0 to width1
, y coordinates from 0 to height1
. (0,0) corresponds to the upper left corner of the grid.
There are different kinds of grids: the type of element that a grid contains is defined by the grid’s type parameter. For instance, Grid[Square]
is a grid where each pair of x and y coordinates contains a Square
object, and Grid[House]
is a grid containing House
objects.
A Grid
is mutable: it is possible to replace an element at a particular GridPos
with another. (Depending on the element type, the elements may be individually mutable, too.) The width and height of a grid never change, however.
Upon creation, a Grid
initializes itself by calling initialElements, which produces an initial state for the grid.
This trait has an alias in the toplevel package o1, so it’s accessible to students simply via import o1.*
.
Parameters
 height

the number of elements in each column of the grid
 width

the number of elements in each row of the grid
Attributes
 Supertypes
An object of type GridPos
represents a pair of integer coordinates. Such a pair can be used to reference a point on a Grid.
An object of type GridPos
represents a pair of integer coordinates. Such a pair can be used to reference a point on a Grid.
The coordinate axes are named x
and y
. In this coordinate system, x
increases “eastwards” and y` increases “southwards”.
GridPos
objects are immutable.
This class has an alias in the toplevel package o1, so it’s accessible to students simply via import o1.*
.
Parameters
 x

an x coordinate
 y

a y coordinate
Attributes
 Companion
 object
 Supertypes