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();
        }
Example #2
0
 private void CompareClones(AbstractCell cell, AbstractCell cloneCell)
 {
     Assert.AreEqual(cell.CanHaveBottom, cloneCell.CanHaveBottom);
     Assert.AreEqual(cell.CanHaveBottomLeft, cloneCell.CanHaveBottomLeft);
     Assert.AreEqual(cell.CanHaveBottomRight, cloneCell.CanHaveBottomRight);
     Assert.AreEqual(cell.CanHaveLeft, cloneCell.CanHaveLeft);
     Assert.AreEqual(cell.CanHaveRight, cloneCell.CanHaveRight);
     Assert.AreEqual(cell.CanHaveTopLeft, cloneCell.CanHaveTopLeft);
     Assert.AreEqual(cell.CanHaveTopRight, cloneCell.CanHaveTopRight);
     Assert.AreEqual(cell.CanHaveTop, cloneCell.CanHaveTop);
     Assert.AreEqual(cell.CurrentGeneration, cloneCell.CurrentGeneration);
 }