Exemple #1
0
        static void ADTreeExample1(ADTreeContext context, ADTreeParser parser)
        {
            context.SetNodeOutcome("ForceDoor", false);
            var input = "LEAF,ForceDoor,100,120";
            Console.WriteLine("ADTree: " + input);
            var adt = parser.Parse(input);

            var expected_success = false;
            var actual_success = EvaluateSuccessAndPrint(adt, context);
            var expected_cost = 100;
            var actual_cost = EvaluateCostAndPrint(adt, context);
            var expected_duration = 120;
            var actual_duration = EvaluateDurationAndPrint(adt, context);

            Debug.Assert(expected_success == actual_success && expected_cost == actual_cost && expected_duration == actual_duration);
        }
Exemple #2
0
        static void ADTreeExample2(ADTreeContext context, ADTreeParser parser)
        {
            context.SetNodeOutcome("BribeGuard", true);
            context.SetNodeOutcome("ForceDoor", false);
            var input = "AND,GrabTreasure,0,2 LEAF,BribeGuard,500,60 LEAF,ForceDoor,100,120";
            Console.WriteLine("ADTree: " + input);
            var adt = parser.Parse(input);

            var expected_success = false;
            var actual_success = EvaluateSuccessAndPrint(adt, context);
            var expected_cost = 600;
            var actual_cost = EvaluateCostAndPrint(adt, context);
            var expected_duration = 182;
            var actual_duration = EvaluateDurationAndPrint(adt, context);

            Debug.Assert(expected_success == actual_success && expected_cost == actual_cost && expected_duration == actual_duration);
        }
Exemple #3
0
        static void ADTreeExample3(ADTreeContext context, ADTreeParser parser)
        {
            context.SetNodeOutcome("HelicopterExit", true);
            context.SetNodeOutcome("EmergencyExit", false);
            context.SetNodeOutcome("BribeGuard", true);
            context.SetNodeOutcome("ForceDoor", true);
            var input = "AND,TreasureStolen,0,0 OR,GetAway,0,0 LEAF,HelicopterExit,500,3 LEAF,EmergencyExit,0,10 AND,GrabTreasure,0,2 LEAF,BribeGuard,500,60 LEAF,ForceDoor,100,120";
            Console.WriteLine("ADTree: " + input);
            var adt = parser.Parse(input);

            var expected_success = true;
            var actual_success = EvaluateSuccessAndPrint(adt, context);
            var expected_cost = 600;
            var actual_cost = EvaluateCostAndPrint(adt, context);
            var expected_duration = 185;
            var actual_duration = EvaluateDurationAndPrint(adt, context);

            Debug.Assert(expected_success == actual_success && expected_cost == actual_cost && expected_duration == actual_duration);
        }