コード例 #1
0
        //Generate new Generation
        public void Next_Generation(Rules rule)
        {
            //Temporary storage for new generation
            Cells_Array next_Gen = new Cells_Array(cells.NumCols, cells.NumRows);

            //Calculate & Build new generation
            for (int row = 0; row < cells.NumRows; row++)
            {
                for (int col = 0; col < cells.NumCols; col++)
                {
                    next_Gen[col, row] = Calculate_Next_Cell(rule, row, col);
                }
            }
            // Apply new generation
            cells = next_Gen;
        }
コード例 #2
0
        public Cell_Handler(int width, int height, int seed)
        {
            cells = new Cells_Array(width, height);

            // Generate first generation based on Seed
            Random r = new Random(seed);

            for (int row = 0; row < height; row++)
            {
                for (int col = 0; col < width; col++)
                {
                    // Populate array with cell states
                    //TODO: Change restriction variable. (NumStates)
                    cells[col, row] = (CellState)r.Next(8);
                }
            }
        }
コード例 #3
0
ファイル: Graphics_Handler.cs プロジェクト: MrFoxington/Demon
        public void draw(Cells_Array _cells)
        {
            Rectangle r;

            int SCALE = 2;

            for (int row = 0; row < height / 2; row++)
            {
                for (int col = 0; col < width / 2; col++)
                {
                    r = new Rectangle(col * SCALE, row * SCALE, SCALE, SCALE);
                    CellState cell = _cells[col, row];
                    Brush     b    = current_Pallet[(int)cell];

                    bufferGraphics.FillRectangle(b, r);
                }
            }

            update();
        }