Example #1
0
        private void goButton_Click(object sender, EventArgs e)
        {
            var numberOfNodes = Convert.ToInt32(nodesBox.Text);
            var branchingRatio = Convert.ToDouble(ratioBox.Text);

            var numberOfDoors = Convert.ToInt32(noDoorsBox.Text);
            var numberOfClues = Convert.ToInt32(noCluesBox.Text);

            var randomSeed = Convert.ToInt32(seedBox.Text);
            var iterations = Convert.ToInt32(iterationBox.Text);

            var visualise = visualiseBox.Checked;

            WriteToLogfile();

            //Set seed
            Random random = new Random(randomSeed);

            if(testOptionBox.SelectedIndex == 0) {
                var graphVisualiser = new GenerateGraphAndVisualise(random);
                graphVisualiser.DoLockClueStressTest(numberOfNodes, branchingRatio, visualise);
            }
            else if(testOptionBox.SelectedIndex == 1)
            {
                var doorAndClueTest = new GenerateDoorAndClueTestAndVisualise(random);
                var unsolveableSituationFound = false;

                for (int i = 0; i < iterations; i++)
                {
                    var solvable = doorAndClueTest.DoLockClueStressTest(numberOfNodes, branchingRatio, numberOfDoors, numberOfClues, visualise);
                    if (!solvable)
                    {
                        MessageBox.Show("Map is not solvable, iteration: " + i);
                        unsolveableSituationFound = true;
                        break;
                    }
                }

                if(!unsolveableSituationFound)
                    MessageBox.Show("All iterations solved");

            }
            else if (testOptionBox.SelectedIndex == 2)
            {
                var doorAndClueTest = new GenerateDoorAndObjectiveTestAndVisualise(random);
                var unsolveableSituationFound = false;

                for (int i = 0; i < iterations; i++)
                {
                    var solvable = doorAndClueTest.DoLockClueStressTest(numberOfNodes, branchingRatio, numberOfDoors, numberOfClues, visualise);
                    if (!solvable)
                    {
                        MessageBox.Show("Map is not solvable, iteration: " + i);
                        unsolveableSituationFound = true;
                        break;
                    }
                }

                if (!unsolveableSituationFound)
                    MessageBox.Show("All iterations solved");

            }
        }
Example #2
0
        private void goButton_Click(object sender, EventArgs e)
        {
            var numberOfNodes  = Convert.ToInt32(nodesBox.Text);
            var branchingRatio = Convert.ToDouble(ratioBox.Text);

            var numberOfDoors = Convert.ToInt32(noDoorsBox.Text);
            var numberOfClues = Convert.ToInt32(noCluesBox.Text);

            var randomSeed = Convert.ToInt32(seedBox.Text);
            var iterations = Convert.ToInt32(iterationBox.Text);

            var visualise = visualiseBox.Checked;

            WriteToLogfile();

            //Set seed
            Random random = new Random(randomSeed);

            if (testOptionBox.SelectedIndex == 0)
            {
                var graphVisualiser = new GenerateGraphAndVisualise(random);
                graphVisualiser.DoLockClueStressTest(numberOfNodes, branchingRatio, visualise);
            }
            else if (testOptionBox.SelectedIndex == 1)
            {
                var doorAndClueTest           = new GenerateDoorAndClueTestAndVisualise(random);
                var unsolveableSituationFound = false;

                for (int i = 0; i < iterations; i++)
                {
                    var solvable = doorAndClueTest.DoLockClueStressTest(numberOfNodes, branchingRatio, numberOfDoors, numberOfClues, visualise);
                    if (!solvable)
                    {
                        MessageBox.Show("Map is not solvable, iteration: " + i);
                        unsolveableSituationFound = true;
                        break;
                    }
                }

                if (!unsolveableSituationFound)
                {
                    MessageBox.Show("All iterations solved");
                }
            }
            else if (testOptionBox.SelectedIndex == 2)
            {
                var doorAndClueTest           = new GenerateDoorAndObjectiveTestAndVisualise(random);
                var unsolveableSituationFound = false;

                for (int i = 0; i < iterations; i++)
                {
                    var solvable = doorAndClueTest.DoLockClueStressTest(numberOfNodes, branchingRatio, numberOfDoors, numberOfClues, visualise);
                    if (!solvable)
                    {
                        MessageBox.Show("Map is not solvable, iteration: " + i);
                        unsolveableSituationFound = true;
                        break;
                    }
                }

                if (!unsolveableSituationFound)
                {
                    MessageBox.Show("All iterations solved");
                }
            }
        }