Esempio n. 1
0
        private void handleNeighbours(pixel IndividualPixel)
        {
            int numNeighbours = IndividualPixel.getNumberNeighbours();

            if (IndividualPixel.isAlive())
            {
                switch (numNeighbours)
                {
                case (2):     //2 or 3 just right
                    break;

                case (3):
                    break;

                default:
                    IndividualPixel.SetStatus(false);     // 0,1 underpopulation - 4,5,6,7 overpopulation
                    break;
                }
            }
            else
            {
                switch (numNeighbours)
                {
                case (3):
                    IndividualPixel.SetStatus(true);
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 2
0
        public Image DrawGrid(grid grid)
        {
            int maxRows = grid.maxRows;
            int maxCols = grid.maxColumns;

            var image = new Image <Rgba32>(maxRows, maxCols);


            for (int row = 0; row < maxRows; row++)
            {
                for (int column = 0; column < maxCols; column++)
                {
                    pixel pixelToDraw = grid.getPixel(row, column);
                    if (pixelToDraw.isAlive())
                    {
                        image[row, column] = Rgba32.White;
                    }
                    else
                    {
                        image[row, column] = Rgba32.Black;
                    }
                }
            }

            return(image);
        }