Initializes a Grid from a List<List<bool>>.
Throws an ArgumentError
if the list is not a boolean matrix,
or if the list is not a rectangular matrix (all rows the same length).
Source
Grid(List<List<bool>> boolGrid) {
if (boolGrid is! List<List<bool>>) {
throw new ArgumentError('Argument `boolGrid` must be of type List<List<bool>>!');
}
if (!_isRectangular(boolGrid)) {
throw new ArgumentError('Argument `boolGrid` must be a rectangular nested List!');
}
for (int y = 0; y < boolGrid.length; y++) {
List<PointNode> nodeRow = new List<PointNode>();
for (int x = 0; x < boolGrid[y].length; x++) {
if (boolGrid[y][x] is! bool) {
throw new ArgumentError('Every element of `boolGrid` must be of type boolean!');
}
PointNode node = new PointNode(new Point(x, y))..walkable = boolGrid[y][x];
nodeRow.add(node);
}
this._grid.add(nodeRow);
}
}