private IEvolutionRule GetEvolutionRule() { INeighbourRule neighbourrule = neighbourrulefactory.Create(grid); IEvolutionRule evolutionrule = evolutionaryrulefactory.CreateEvolutionRule(neighbourrule); return(evolutionrule); }
/// <summary> /// Apply a single generation of evolution /// </summary> public void Evolve() { IEvolutionRule evolutionrule = GetEvolutionRule(); Cell evolvedCell = null; generationnumber++; foreach (Cell cell in grid) { evolvedCell = evolutionrule.EvolveCell(cell); cell.StoreNewState(evolvedCell.IsAlive); } foreach (Cell cell in grid) { cell.ApplyNewState(); } }