private void FeedLine(string gridLine, int row) { var cellColors = gridLine.ToCharArray().Select(x => x.ToString()).Select(int.Parse).ToList(); for (int col = 0; col < cellColors.Count; col++) { var cellCoordinates = new CellCoordinates(row, col); this.Cells[row, col] = new Cell((CellColor)cellColors[col], cellCoordinates); } }
public Cell(CellColor cellColor, CellCoordinates cellCoordinates) { this.CellColor = cellColor; this.CellCoordinates = cellCoordinates; this.neighboursCellCoordinates = new List <CellCoordinates>() { new CellCoordinates(this.CellCoordinates.Row - 1, this.CellCoordinates.Col - 1), new CellCoordinates(this.CellCoordinates.Row - 1, this.CellCoordinates.Col), new CellCoordinates(this.CellCoordinates.Row - 1, this.CellCoordinates.Col + 1), new CellCoordinates(this.CellCoordinates.Row, this.CellCoordinates.Col - 1), new CellCoordinates(this.CellCoordinates.Row, this.CellCoordinates.Col + 1), new CellCoordinates(this.CellCoordinates.Row + 1, this.CellCoordinates.Col - 1), new CellCoordinates(this.CellCoordinates.Row + 1, this.CellCoordinates.Col), new CellCoordinates(this.CellCoordinates.Row + 1, this.CellCoordinates.Col + 1), }; this.GenerationsWhereGreen = this.CellColor == CellColor.Green ? 1 : 0; }