Beispiel #1
0
        public void NoBehavioursThenNullSelectionTest()
        {
            var ai      = new UtilityAi();
            var context = new UaiContext();

            Assert.IsNull(ai.Select(context));
        }
Beispiel #2
0
        public void BehaviourSelectionTest()
        {
            var ai      = new UtilityAi();
            var context = new UaiContext();
            var b1      = new Behaviour();

            b1.NameId = "b1";
            var b2 = new Behaviour();

            b2.NameId = "b2";
            var consideration1 = new BehaviourConsideration1();
            var consideration2 = new BehaviourConsideration2();

            b1.AddConsideration(consideration1);
            b2.AddConsideration(consideration2);

            var a1 = new MockAction();

            a1.NameId = "a1";
            var fo1 = new ConstantUtilityOption();

            fo1.SetAction(a1);
            b1.AddOption(fo1);
            var a2 = new MockAction();

            a2.NameId = "a2";
            var fo2 = new ConstantUtilityOption();

            fo2.SetAction(a2);
            b2.AddOption(fo2);

            ai.AddBehaviour(b1);
            ai.AddBehaviour(b2);

            context.Val1 = 1.0f;
            context.Val2 = 0.0f;
            var sel1 = ai.Select(context);

            Assert.That(sel1 == a1);
            context.Val1 = 0.0f;
            context.Val2 = 1.0f;
            var sel2 = ai.Select(context);

            Assert.That(sel2 == a2);
        }