示例#1
0
 static int EvaluateCostAndPrint(IADTreeNode node, ADTreeContext context)
 {
     EvaluateCostVisitor v = new EvaluateCostVisitor();
     var value = v.GetValue(node, v, context);
     Console.WriteLine("Minimum attack cost: " + value);
     return value;
 }
示例#2
0
文件: Visitor.cs 项目: AstRyou/All
 public int GetValue(IADTreeNode a, EvaluateCostVisitor b, ADTreeContext c)
 {
     if (a is LEAF)
     {
         return((int)a.Accept(this));
     }
     else if (a is OR)
     {
         int v1 = GetValue(a.childs[0], b, c);
         int v2 = GetValue(a.childs[1], b, c);
         return(v1 > v2 ? v2 : v1);
     }
     else
     {
         return(GetValue(a.childs[0], b, c) + GetValue(a.childs[1], b, c));
     }
 }