public void Cycle() { if (OldGeneration.Count > 0) { for (int i = 0; i < OldGeneration.Count; i++) { SetNeighbours(OldGeneration[i]); } OldGeneration.AddRange(_neighbours); _neighbours.Clear(); foreach (var cell in OldGeneration) { Cell newCell = Rules.Apply(cell); _cellService.DrawCell(newCell); if (newCell.State == State.ALive) { newCell.Neighbours = 0; NewGeneration.Add(newCell); } } OldGeneration = new List <Cell>(NewGeneration); NewGeneration.Clear(); } }