Grid
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 width-1, y coordinates from 0 to height-1. (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 top-level 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
- Graph
-
- Supertypes
- Known subtypes
-
class RobotWorld
