Example #1
0
        public void ApplyRule(AbstractCell cell, List<AbstractCell> neighbours)
        {
            if (cell == null)
                throw new ArgumentNullException("cell");
            if (neighbours == null)
                throw new ArgumentNullException("neighbours");

            int alive = neighbours.Count(neighbour => neighbour.IsAlive);

            if ((alive == 2 && cell.IsAlive) || alive == 3)
                cell.ShouldLive();
            else
                cell.ShouldDie();
        }