Esempio n. 1
0
        internal GridData Randomize(GridSize gridSize)
        {
            var newData = new CellStateEnum[gridSize.NumberRows, gridSize.NumberCols];

            var numberCells = gridSize.NumberRows * gridSize.NumberCols;

            Random randomizer = new Random();

            for (int cellPos = 0; cellPos < numberCells; cellPos++)
            {
                var rowPos = IncrementEvery(cellPos, gridSize.NumberCols);
                var colPos = cellPos % gridSize.NumberCols;
                newData[rowPos, colPos] = GetRandomState(randomizer);
            }

            return(new GridData(_iodevice, newData));
        }
Esempio n. 2
0
        public Grid WithRandomData(GridSize gridSize)
        {
            _data = _data.Randomize(gridSize);

            return(this);
        }