Esempio n. 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     //YES BUTTON
     if (status == false)
     {
         count++;
         TempRoot = TempRoot.GetYesNode();
         if (TempRoot.IsPrediction())
         {
             q = TempRoot.GetQuestion();
             MakeQues();
         }
         else
         {
             q = TempRoot.GetQuestion();
             MakePrediction();
         }
     }
     else
     {
         this.Hide();
         WinningForm t = new WinningForm(0);
         t.ShowDialog();
     }
 }
        public BTNode AddingRoot()
        {//adding root for new yes or no node or question
            Game.start();
            Queue <BTNode> queue = new Queue <BTNode>();

            queue.Enqueue(Game.Roots);

            while (queue.Count > 0)
            {
                BTNode t = queue.Dequeue();
                if (t.GetQuestion() == TRoot.GetQuestion())
                {
                    return(t);
                }
                if (t.GetYesNode() != null)
                {
                    queue.Enqueue(t.GetYesNode());
                }
                if (t.GetNoNode() != null)
                {
                    queue.Enqueue(t.GetNoNode());
                }
            }
            return(null);
        }
Esempio n. 3
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     Game.start();
     TempRoot = Game.Roots;
     q        = TempRoot.GetQuestion();
     MakeQues();
     label2.Text = "Question No:";
 }
Esempio n. 4
0
        public void PreOrderDisplay(BTNode Root)
        {
            if (Root == null)
            {
                return;
            }

            Console.WriteLine(Root.GetQuestion());
            PreOrderDisplay(Root.GetYesNode());
            PreOrderDisplay(Root.GetNoNode());
        }
        private void button1_Click(object sender, EventArgs e)
        {//ok button
            if (count == 0)
            {
                UserAnswer    = textBox1.Text.ToString();
                label1.Text   = "Please enter a question to distinguish a " + TRoot.GetQuestion() + " From " + UserAnswer;
                textBox1.Text = " ";
            }

            if (count == 1)
            {
                label3.Text      = "If you were thinking of a " + UserAnswer + ", \nwhat would the answer to that question be?";
                UserQuestion     = textBox1.Text.ToString();
                textBox1.Visible = false;
                label1.Visible   = false;
                button1.Visible  = false;
                button2.Visible  = true;
                button3.Visible  = true;
            }
            count++;
        }
Esempio n. 6
0
 private void button2_Click(object sender, EventArgs e)
 {
     //NO BUTTON
     if (status == false)
     {
         TempRoot = TempRoot.GetNoNode();
         if (TempRoot.IsPrediction())
         {
             q = TempRoot.GetQuestion();
             MakeQues();
         }
         else
         {
             q = TempRoot.GetQuestion();
             MakePrediction();
         }
     }
     else
     {
         this.Hide();
         UpdateknowledgeScreen t = new UpdateknowledgeScreen(TempRoot);
         t.ShowDialog();
     }
 }
Esempio n. 7
0
        public Queue PreOrderWrite()
        {
            if (Roots == null)
            {
                return(null);
            }

            Stack stack  = new Stack();
            Queue output = new Queue();

            stack.push(Roots);

            while (!stack.IsEmpty())
            {
                BTNode temp = stack.pop();
                output.Enqueue(temp.GetQuestion());

                if (temp.GetYesNode() != null)
                {
                    stack.push(temp.GetYesNode());
                }
                else
                {
                    output.Enqueue("x");
                }
                if (temp.GetNoNode() != null)
                {
                    stack.push(temp.GetNoNode());
                }
                else
                {
                    output.Enqueue("x");
                }
            }
            return(output);
        }