The Board
Introduction
A Board object is by default a grid consisting of multiple colored squares.
Square(s)
RowCol(s)
Each Square defines a unique location on the board that is captured by a Cartesian coordinate. In Colored Trails, the coordinates are represented by RowCol objects. A row on the Board represents a point on the Y-axis and a column represents a point on the X-axis. An example:
A Board object
The board class is part of the edu.harvard.eecs.airg.coloredtrails.shared.types package. The main Board constructor takes two arguments: the number of rows and the number of columns.
public Board(int rows, int cols) { put("Rows", new Integer(rows)); put("Cols", new Integer(cols)); for (int r = 0; r < rows; r++) for (int c = 0; c < cols; c++) put("Square." + r + "-" + c, new Square("snow")); }
The board will usually be defined in the Config file, like so:
board = new Board(4,4);