Example #1
0
        public OptimalGenerationTester(int ranSeed)
        {
            int testSize = 1000;

            for (int n = 4; n < 12; n++)//Size of board
            {
                Console.WriteLine("For a board size of " + n);
                Console.WriteLine("Seed: " + ranSeed);
                Console.WriteLine("Number of tests: " + testSize);
                for (int i = 1; i <= n; i++)//Boards to generate
                {
                    int avg = 0;
                    for (int k = 0; k < testSize; k++)//Tests
                    {
                        InformedSearch s = new InformedSearch(n, i, ranSeed);
                        avg += s.GetNumSwaps();
                    }
                    Console.WriteLine(string.Format("For {0} initial board generations, {1} average swaps", i, (avg / testSize)));
                }
                Console.ReadLine();
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            //variables
            int size;
            int seed;

            //Set up
            Console.WriteLine("Input board size >= 4. Default = 8");
            size = (Int32.TryParse(Console.ReadLine(), out size) && size > 3) ? size : 8;
            Console.WriteLine("Board size of " + size + " selected");

            Console.WriteLine("Input seed. Default = Current Time");
            seed = Int32.TryParse(Console.ReadLine(), out seed) ? seed : (int)Math.Abs((int)DateTime.Now.ToBinary());
            Console.WriteLine("Seed of " + seed + " selected");

            Console.WriteLine();
            //Actual searches

            Console.WriteLine("Press Enter to run blindsearch");
            Console.ReadLine();
            var         timer = System.Diagnostics.Stopwatch.StartNew();
            BlindSearch blind = new BlindSearch(size);

            Console.WriteLine("Blind search compleated in: " + timer.ElapsedMilliseconds + "ms");

            timer.Reset();

            Console.WriteLine("\n\nPress Enter to run Hueristic search");
            Console.ReadLine();

            timer.Start();
            InformedSearch huristic = new InformedSearch(size, seed);

            Console.WriteLine("Hueristic search compleated in: " + timer.ElapsedMilliseconds + "ms");
            timer.Stop();

            Console.ReadLine();
        }