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); }
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 void PreOrderDisplay(BTNode Root) { if (Root == null) { return; } Console.WriteLine(Root.GetQuestion()); PreOrderDisplay(Root.GetYesNode()); PreOrderDisplay(Root.GetNoNode()); }
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); }