clockwise90 method

GridWorld clockwise90()

Copy this as a clockwise 90 degree rotation.

Implementation

GridWorld clockwise90() {
  final newCells = List<bool>.filled(_numRows * _numCols, false);
  int newIndex(int i, int j) => (j * _numRows) + (_numRows - 1 - i);
  for (var i = 0; i < _numRows; i++) {
    for (var j = 0; j < _numCols; j++) {
      newCells[newIndex(i, j)] = isAlive(i, j);
    }
  }
  return GridWorld(_numCols, newCells);
}