Пример #1
0
        private void centerToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            //Stop the sim if it's running
            if (UpdateTimer.Enabled) UpdateTimer.Stop();

            //Make sure the sim isn't null
            if (Sim == null) Sim = new AutoSim(Size);

            //Re-seed the simulation
            Sim.Grid = Simulation.GetBlankGrid(Size);

            int centerval = Sim.Grid.Length / 2;
            Sim.Grid[centerval][centerval] = true;
            Sim.Grid[centerval][centerval - 1] = true;
            Sim.Grid[centerval][centerval + 1] = true;
            Sim.Grid[centerval + 1][centerval] = true;
            Sim.Grid[centerval - 1][centerval] = true;
            Sim.Grid[centerval - 1][centerval - 1] = true;
            Sim.Grid[centerval + 1][centerval + 1] = true;
            Sim.Grid[centerval + 1][centerval - 1] = true;
            Sim.Grid[centerval - 1][centerval + 1] = true;

            //Scale the grid
            ScaleGrid();

            //Reset the generation count
            GenerationCount = 0;

            //Start the timer
            UpdateTimer.Start();
        }
Пример #2
0
        private void tRUERANDToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Stop the sim if it's running
            if (UpdateTimer.Enabled) UpdateTimer.Stop();

            //Create a new autosim
            Sim = new AutoSim(Size, Simulation.GenerateRandomDouble(0.1, 0.9));

            Sim.SearchRadius = Simulation.RandomGen.Next(1, 10);
            Sim.OvercrowdingCount = Simulation.RandomGen.Next(1, (Sim.SearchRadius * 2) * (Sim.SearchRadius * 2));
            Sim.DeathCount = Simulation.RandomGen.Next(1, (Sim.SearchRadius * 2) * (Sim.SearchRadius * 2));
            Sim.BirthCount = Simulation.RandomGen.Next(1, (Sim.SearchRadius * 2) * (Sim.SearchRadius * 2));

            int roll = Simulation.RandomGen.Next(0, 5);
            if (roll == 0) Sim.NeighborSearchAlgorithm = NeighborType.Moore;
            if (roll == 1) Sim.NeighborSearchAlgorithm = NeighborType.Neumann;
            if (roll == 2) Sim.NeighborSearchAlgorithm = NeighborType.Totty;
            if (roll == 3) Sim.NeighborSearchAlgorithm = NeighborType.Diagonal;
            if (roll == 4) Sim.NeighborSearchAlgorithm = NeighborType.AntiDiagonal;

            //Scale the grid
            ScaleGrid();

            //Reset the generation count
            GenerationCount = 0;

            //Start the timer
            UpdateTimer.Start();
        }
Пример #3
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            //Stop the sim if it's running
            if (UpdateTimer.Enabled) UpdateTimer.Stop();

            //Create a new autosim
            Sim = new AutoSim(Size, 0.7);

            //Scale the grid
            ScaleGrid();

            //Reset the generation count
            GenerationCount = 0;

            //Start the timer
            UpdateTimer.Start();
        }
Пример #4
0
        private void sR3DC4OC7ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Stop the sim if it's running
            if (UpdateTimer.Enabled) UpdateTimer.Stop();

            //Create a new autosim
            Sim = new AutoSim(Size, 0.7);
            Sim.SearchRadius = 3;
            Sim.OvercrowdingCount = 13;
            Sim.BirthCount = 4;

            //Scale the grid
            ScaleGrid();

            //Reset the generation count
            GenerationCount = 0;

            //Start the timer
            UpdateTimer.Start();
        }
Пример #5
0
        private void ReSeedSim(double SeedVal)
        {
            //Stop the sim if it's running
            if (UpdateTimer.Enabled) UpdateTimer.Stop();

            //Make sure the sim isn't null
            if (Sim == null) Sim = new AutoSim(Size);

            //Re-seed the simulation
            Sim.Grid = Simulation.SeedSimulation(Size, SeedVal);

            //Scale the grid
            ScaleGrid();

            //Reset the generation count
            GenerationCount = 0;

            //Start the timer
            UpdateTimer.Start();
        }
Пример #6
0
        private void randomTottyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Stop the sim if it's running
            if (UpdateTimer.Enabled) UpdateTimer.Stop();

            //Create a new autosim
            Sim = new AutoSim(Size, Simulation.GenerateRandomDouble(0.1, 0.9));

            Sim.SearchRadius = Simulation.RandomGen.Next(2, 4);
            Sim.OvercrowdingCount = Simulation.RandomGen.Next(1, (Sim.SearchRadius * 2) * (Sim.SearchRadius * 2));
            Sim.DeathCount = Simulation.RandomGen.Next(1, Sim.OvercrowdingCount + 1);
            Sim.BirthCount = Simulation.RandomGen.Next(1, Sim.OvercrowdingCount + 1);
            Sim.NeighborSearchAlgorithm = NeighborType.Totty;

            //Scale the grid
            ScaleGrid();

            //Reset the generation count
            GenerationCount = 0;

            //Start the timer
            UpdateTimer.Start();
        }
Пример #7
0
        private void OFD_RuleSet_FileOk(object sender, CancelEventArgs e)
        {
            //Load the file to memory
            SerializableRuleSet Rules = Serialization.DeserializeObject<SerializableRuleSet>(OFD_RuleSet.FileName);

            //Create a new sim
            Sim = new AutoSim(Size);

            //Copy over the rule information
            Sim.BirthCount = Rules.BirthCount;
            Sim.DeathCount = Rules.DeathCount;
            Sim.OvercrowdingCount = Rules.OvercrowdingCount;
            Sim.SearchRadius = Rules.SearchRadius;
            Sim.NeighborSearchAlgorithm = Rules.NeighborSearchAlgorithm;

            //Now re-seed the simulation
            Sim.Grid = Simulation.SeedSimulation(Size, 0.7);

            MessageBox.Show("Automaton simulation ruleset successfully loaded...", "Load Successful!", MessageBoxButtons.OK);
            GenerationCount = 0;
            UpdateTimer.Start();
        }
Пример #8
0
        private void OFD_AutoSim_FileOk(object sender, CancelEventArgs e)
        {
            //Load the file to memory
            Sim = Serialization.DeserializeObject<AutoSim>(OFD_AutoSim.FileName);

            MessageBox.Show("Automaton simulation successfully loaded...", "Load Successful!", MessageBoxButtons.OK);
            GenerationCount = 0;
            UpdateTimer.Start();
        }