Ejemplo n.º 1
0
        public Grid Next(IEnumerable<IRule> rules)
        {
            var newCells = new List<Point>();

            for (var x = 0; x < Size; x++)
            {
                for (var y = 0; y < Size; y++)
                {
                    var point = new Point(x, y);

                    var lives = rules.Any(r => r.Apply(point, Cells.Contains(point), point.LivingNeighbors(Cells)));

                    if (lives)
                    {
                        newCells.Add(point);
                    }
                }
            }

            return new Grid(newCells, Size);
        }