コード例 #1
0
        static AddNewCellToList EvaluateNextGenerationOfCell(Cell cell)
        {
            foreach (ExecuteRuleOnCell rule in rules)
            {
                AddNewCellToList resultingCell;
                if (rule.TryExecute(cell, out resultingCell)) return resultingCell;
            }

            return new AddNewCellToList(cell.Point, cell.State);
        }
コード例 #2
0
        public Cell ToList(CellList list)
        {
            if (list.Cells.Any(c => c.Point == _position))
            {
                throw new Exception("A cell already exists in that position");
            }

            var cell = new Cell(list, _position, _state);

            list.Cells.Add(cell);

            return cell;
        }
コード例 #3
0
        IEnumerable<Cell> FindOrGenerateNeighbourCells(CellList list, Cell cell)
        {
            IEnumerable<Point> points = new GeneratePointsAroundPoint().Generate(cell.Point);

            foreach (Point point in points)
            {
                Cell match = new FindCellAtPosition().Find(list, point);
                if (match != null)
                {
                    yield return match;
                }
                else
                {
                    yield return new AddNewCellToList(point, CellState.Dead).ToList(list);
                }
            }
        }
コード例 #4
0
 void WasEvaluated(Cell cell)
 {
     _evaluatedPoints.Add(cell.Point);
 }
コード例 #5
0
 bool NotYetEvaluated(Cell cell)
 {
     return !_evaluatedPoints.Contains(cell.Point);
 }