コード例 #1
0
ファイル: ClassicRule.cs プロジェクト: hemant1906/McK.Life
        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();
        }
コード例 #2
0
ファイル: CellTests.cs プロジェクト: hemant1906/McK.Life
 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);
 }