Пример #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;
        }
        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);
                }
            }
        }
 void WasEvaluated(Cell cell)
 {
     _evaluatedPoints.Add(cell.Point);
 }
 bool NotYetEvaluated(Cell cell)
 {
     return !_evaluatedPoints.Contains(cell.Point);
 }