// 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()); }
// 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()); }