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); }
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); }
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(); } }