コード例 #1
0
        // Rule 3: Any live cell with two or three live neighbours lives on to the next generation
        public LivenessRuleResult Apply(Cell cell, int neighboursCount)
        {
            if (cell.IsAlive && (neighboursCount == 2 || neighboursCount == 3))
            {
                return(LivenessRuleResult.AppliedWithResult(true));
            }

            return(LivenessRuleResult.NotApplied());
        }
コード例 #2
0
ファイル: LivenessRule1.cs プロジェクト: hbiarge/Katas
        // Rule 1: Any live cell with fewer than two live neighbours dies, as if caused by underpopulation
        public LivenessRuleResult Apply(Cell cell, int neighboursCount)
        {
            if (cell.IsAlive && neighboursCount < 2)
            {
                return(LivenessRuleResult.AppliedWithResult(false));
            }

            return(LivenessRuleResult.NotApplied());
        }