예제 #1
0
 //second constructor used for user input simulation
 public SimulationManager(Bitmap pattern, Graphics canvas, Graphics formGraphics, Rectangle bounds, LaplacianDelegate lapFunc, IColourPicker colourScheme,
     int cellSize, int gridSize, double diffA, double diffB, double feedA, double killB)
 {
     this.pattern = pattern;
     this.canvas = canvas;
     this.formGraphics = formGraphics;
     this.cellSize = cellSize;
     this.gridSize = gridSize;
     this.feedA = feedA;
     this.killB = killB;
     grid = new Grid(canvas, bounds, lapFunc, colourScheme, cellSize, gridSize, diffA, diffB, feedA, killB);
 }
예제 #2
0
        //runs the batch simulation
        public void RunBatchSimulation()
        {
            feedA = 0.001;
            killB = 0.001;
            double diffA = 0;
            double diffB = 0;
            IColourPicker colourScheme = new GrayScaleColours();
            for(int i = 0; i < 3; i++)
            {
                //set laplacian function and related diffusion rates
                if(i == 0)
                {
                    lapFunc = LaplacianFunctions.PerpendicularLaplacian;
                    diffA = perpDiffA;
                    diffB = PerpDiffB;
                }
                else if (i == 1)
                {
                    lapFunc = LaplacianFunctions.ConvolutionLaplacian;
                    diffA = convDeltDiffA;
                    diffB = convDeltDiffB;
                }
                else if (i == 2)
                {
                    lapFunc = LaplacianFunctions.DeltaMeansLaplacian;
                    diffA = convDeltDiffA;
                    diffB = convDeltDiffB;
                }

                //changes feed A until it reaches 0.099
                while(feedA <= 0.099)
                {
                    //changes kill b untill it reaches 0.099
                    while (killB <= 0.099)
                    {
                        //makes a new grid with those numbers
                        grid = new Grid(canvas, bounds, lapFunc, colourScheme, cellSize, gridSize, diffA, diffB, feedA, killB);
                        //runs throught the simulation for 5000 iterations - enough to become stable
                        for (int j = 0; j < numOfIterations; j++)
                        {
                            grid.GetCellsNextValues();
                            grid.UpdateCellsValues();
                        }
                        //once it has become stable draws to screen then saves the image
                        grid.DrawGrid();
                        formGraphics.DrawImage(pattern, 0, 0);
                        SaveImage();

                        killB += 0.001;
                    }
                    feedA += 0.001;
                    killB = 0.001;

                }
            }
        }