Пример #1
0
 static bool EvaluateSuccessAndPrint(IADTreeNode node, ADTreeContext context)
 {
     EvaluateSuccessVisitor v = new EvaluateSuccessVisitor();
     var value = v.GetValue(node, v, context);
     if (value)
         Console.WriteLine("Evaluated: true");
     else
         Console.WriteLine("Evaluated: false");
     return value;
 }
Пример #2
0
        public bool GetValue(IADTreeNode a, EvaluateSuccessVisitor b, ADTreeContext c)
        {
            if (a.childs.Count > 0)
            {
                if (a is AND)
                {
                    return(GetValue(a.childs[0], b, c) && GetValue(a.childs[1], b, c));
                }
                else
                {
                    return(GetValue(a.childs[0], b, c) || GetValue(a.childs[1], b, c));
                }
            }

            bool?outcome = c.GetNodeOutcome((string)a.Accept(b));

            if (outcome == null)
            {
                return(new Random().Next(0, 100) > 50 ? true : false);
            }
            return(outcome.Value);
        }