Example #1
0
        private IEvolutionRule GetEvolutionRule()
        {
            INeighbourRule neighbourrule = neighbourrulefactory.Create(grid);
            IEvolutionRule evolutionrule = evolutionaryrulefactory.CreateEvolutionRule(neighbourrule);

            return(evolutionrule);
        }
Example #2
0
        /// <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();
            }
        }