public class Cell { public var alive as bool; private var row as usize; private var column as usize; public this(row as usize, column as usize) { this(row, column, false); } public this(row as usize, column as usize, alive as bool) { this.row = row; this.column = column; this.alive = alive; } public getCellNextTick(currentGrid as ConwayGrid) as Cell { //+2 because upperbound exclusive var range = currentGrid[(row - 1) .. (row + 2), (column - 1) .. (column + 2)]; var aliveCellsIn3x3Grid = range.filter(element => element.alive).length; if(!alive) { return new Cell(row, column, aliveCellsIn3x3Grid == 3); } //2. Any live cell with two or three live neighbours lives on to the next generation. return new Cell(row, column, aliveCellsIn3x3Grid == 3 || aliveCellsIn3x3Grid == 4); } }