コード例 #1
0
ファイル: Result.cs プロジェクト: isan0786/Knight-Tour
        static void Main(string[] args)
        {
            Choices c = new Choices();
            int     j = 0;
            int     i = 0;

            while (i < 10)
            {
                //  c.intelligent(5, 5); get full score
                c.intelligent(5, 5);
                i++;
            }
            Console.WriteLine("------------------------------------");
            while (j < 10)
            {
                //  c.intelligent(5, 5); get full score
                c.nonIntelligent(5, 5);
                j++;
            }
            Console.ReadKey();
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: isan0786/Knight-Tour
        private void button1_Click(object sender, EventArgs e)
        {
            //   Console.WriteLine("column is " + column + " row is" + row + " method is" + method + " times is" + noOfTimes + " name is" + name);
            if (row != "" && column != "" && noOfTimes != "" && name != "")
            {
                if ((Convert.ToInt32(row) >= 0 && Convert.ToInt32(row) <= 7) && (Convert.ToInt32(column) >= 0 && Convert.ToInt32(column) <= 7) && (Convert.ToInt32(noOfTimes) > 0))
                {
                    //  textBox3.Text = "1 to " + noOfTimes.ToString();
                    counter = Convert.ToInt32(noOfTimes);

                    if (method == "HeuristicsMethod")
                    {
                        result = "";
                        while (counter > times)
                        {
                            Choices c = new Choices();

                            Choices.saver += "Chess Board " + (times + 1).ToString();
                            //  c.intelligent(5, 5); get full score
                            moves = c.intelligent(Convert.ToInt32(row), Convert.ToInt32(column));

                            numbers.Add(moves);

                            averageMoves += moves;

                            //   Console.WriteLine("------------------------------------ intelli");

                            //  c.intelligent(5, 5); get full score

                            times++;

                            result += "Trial " + times.ToString() + ":   The knight was able to successfully touch " + moves + " squares\r\n\r\n";
                        }
                        times = 0;
                    }
                    else
                    {
                        result = "";

                        while (counter > times)
                        {
                            Choices c = new Choices();

                            Choices.saver += "Chess Board " + (times + 1).ToString();
                            //  c.intelligent(5, 5); get full score
                            moves = Choices.nonIntelligent(Convert.ToInt32(row), Convert.ToInt32(column));
                            numbers.Add(moves);
                            averageMoves += moves;
                            //   Console.WriteLine("------------------------------------ non intelli");

                            //  c.intelligent(5, 5); get full score

                            times++;


                            result += "Trial " + times.ToString() + ":   The knight was able to successfully touch " + moves + " squares\r\n\r\n";
                        }

                        times = 0;
                    }
                    //   Console.WriteLine(result);
                    using (StreamWriter Writer = new StreamWriter(name + method + ".txt"))
                    {
                        Writer.WriteLine(result);
                    }
                }
                else
                {
                    Console.WriteLine("The values that you gave are not good enough , Please provide the right input");
                }
            }
            else
            {
                Console.WriteLine("You didn't fill one of the text feild, Please provide the right input");
            }

            averageMoves      = averageMoves / Convert.ToInt32(noOfTimes);
            richTextBox1.Text = Choices.saver;
            label8.Text       = name;

            if (Convert.ToInt32(noOfTimes) == 2)
            {
                MessageBox.Show("The average is " + averageMoves);
            }
            if (Convert.ToInt32(noOfTimes) > 2)
            {
                MessageBox.Show("The average is " + averageMoves);
                MessageBox.Show("The standard deviation is " + getStandardDeviation(numbers));
            }
            Choices.saver = "";
            averageMoves  = 0;
            numbers.Clear();
        }