コード例 #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));
     }
 }