Ejemplo n.º 1
0
 public static IGrid PreConfiguredGrid()
 {
     var grid = new Grid(new GridSize(4, 3));
     var cell = new Cell(new Position(2, 2), true);
     grid.MakeCell(cell);
     cell = new Cell(new Position(3, 1), true);
     grid.MakeCell(cell);
     return grid;
 }
Ejemplo n.º 2
0
        public static IGrid CreateGrid(IGridSize gridSize, IEnumerable<ICell> liveCells)
        {
            var grid = new Grid(gridSize);
            //Mark all cells
            foreach (var liveCell in liveCells)
            {
                grid.MakeCell(liveCell.Position, liveCell.Alive);
            }

            return grid;
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Create new instance of current grid
        /// </summary>
        /// <param name="currentGrid"> Current grid </param>
        /// <returns> Retunr new grid instance </returns>
        public IGrid Copy(IGrid currentGrid)
        {
            var gridCopy = new Grid(currentGrid.GridSize);
            foreach (
                var newCell in currentGrid.GetAllCurrentCellInfo().Select(cell => new Cell(cell.Position, cell.Alive)))
            {
                gridCopy.MakeCell(newCell);
            }

            return gridCopy;
        }