public void ContainsAiTest1()
        {
            _aIs.ClearAll();
            var ai = new UtilityAi("name", _aIs);

            Assert.That(_aIs.Contains("name"));
        }
Beispiel #2
0
        public void AddNonExistentBehaviourReturnsFalseTest()
        {
            _aic.Clear();
            var ai = new UtilityAi("testai", _aic);

            Assert.That(ai.AddBehaviour("some"), Is.False);
        }
Beispiel #3
0
        public void NoBehavioursThenNullSelectionTest()
        {
            var ai      = new UtilityAi();
            var context = new UaiContext();

            Assert.IsNull(ai.Select(context));
        }
Beispiel #4
0
        public void RemoveNonExistentStringBehaviourReturnsFalseTest()
        {
            _aic.Clear();
            var ai = new UtilityAi("testai", _aic);

            Assert.That(ai.RemoveBehaviour("some"), Is.False);
        }
Beispiel #5
0
        public void ThinkRecursionDetectionTest()
        {
            _aic.ClearAll();
            var s = new Scheduler();
            // The main AI
            var ta            = new AiTransition("TransitionToCircularAi", "circularAi", _aic);
            var circularAi    = new UtilityAi("circularAi", _aic);
            var coreBehaviour = new Behaviour("cb", _bc);

            coreBehaviour.Selector = new MaxUtilitySelector();
            var circularOption = new ConstantUtilityOption("recursive", _oc);

            circularOption.DefaultUtility = new Utility(1f, 1f);
            circularOption.SetAction("TransitionToCircularAi");

            Assert.That(coreBehaviour.AddOption("recursive"), Is.True);
            Assert.That(circularAi.AddBehaviour(coreBehaviour.NameId), Is.True);

            var dm = new DecisionMaker(circularAi, _toon, s);

            Assert.Throws <DecisionMakerBase.PotentialCircularDependencyException>(dm.Think);
            try {
                dm.Think();
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #6
0
        public void SetNullSelectorDoesNotChangeSelectorTest()
        {
            var ai = new UtilityAi();

            Assert.IsNotNull(ai.Selector);
            ai.Selector = null;
            Assert.IsNotNull(ai.Selector);
        }
Beispiel #7
0
        public void RemoveStringBehaviourReturnsTrueTest()
        {
            _aic.Clear();
            var ai = new UtilityAi("testai", _aic);

            Assert.That(ai.AddBehaviour("b1"), Is.True);
            Assert.That(ai.RemoveBehaviour("b1"), Is.True);
        }
Beispiel #8
0
        public void AddExistingStringBehaviourReturnsFalseTest()
        {
            _aic.Clear();
            var ai = new UtilityAi("testai", _aic);

            Assert.That(ai.AddBehaviour("b1"), Is.True);
            Assert.That(ai.AddBehaviour("b1"), Is.False);
        }
        public void AddAiTest()
        {
            _aIs.ClearAll();
            var ai = new UtilityAi();

            ai.NameId = "some";
            Assert.That(_aIs.Add(ai));
            Assert.That(_aIs.Add(ai) == false);
        }
Beispiel #10
0
        public void DuplicateIsNotAddedTest()
        {
            var ai = new UtilityAi();
            var b  = new Behaviour();

            b.NameId = "some";
            Assert.That(ai.AddBehaviour(b), Is.True);
            Assert.That(ai.AddBehaviour(b), Is.False);
        }
        public void ContainsAiTest2()
        {
            _aIs.ClearAll();
            var ai = new UtilityAi();

            ai.NameId = "name";
            _aIs.Add(ai);
            Assert.That(_aIs.Contains("name"));
        }
        public void ClearTest()
        {
            _aIs.ClearAll();
            var ai = new UtilityAi("name", _aIs);

            Assert.That(_aIs.Contains("name"));
            _aIs.Clear();
            Assert.That(_aIs.Contains("name") == false);
        }
Beispiel #13
0
        public void RepeatedDeletionIsOkayTest()
        {
            var ai = new UtilityAi();
            var b  = new Behaviour();

            b.NameId = "beh";
            Assert.That(ai.AddBehaviour(b), Is.True);
            Assert.That(ai.RemoveBehaviour(b), Is.True);
            Assert.That(ai.RemoveBehaviour(b), Is.False);
        }
Beispiel #14
0
        public void LinkUtilityAiActionConstructionTest()
        {
            var ai = new UtilityAi();

            Assert.IsNotNull(ai);
            var action = new AiTransition(ai);

            Assert.IsNotNull(action);
            Assert.IsNotNull(action.TargetAi);
        }
        public void CreateAiTest()
        {
            _aIs.ClearAll();
            var ai = new UtilityAi();

            ai.NameId = "some";
            _aIs.Add(ai);
            var newAi = _aIs.Create("some");

            Assert.AreEqual(ai.NameId, newAi.NameId);
            Assert.AreNotEqual(ai, newAi);
        }
Beispiel #16
0
        public void TargetAiDoesNotExistExceptionTest()
        {
            _aIs.ClearAll();
            var transition = new AiTransition("transition", "ai5", _aIs);

            Assert.Throws <AiTransition.TargetAiDoesNotExistException>(() => {
                var t = transition.TargetAi;
            });
            var ai5 = new UtilityAi("ai5", _aIs);

            Assert.DoesNotThrow(() => {
                var t = transition.TargetAi;
            });
        }
Beispiel #17
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);
        }
Beispiel #18
0
 protected override void ConfigureAi()
 {
     Ai = new UtilityAi(AiDefs.ToonAi, AIs);
     Ai.AddBehaviour(BehaviourDefs.LiveLong);
     Ai.AddBehaviour(BehaviourDefs.Prosper);
 }
Beispiel #19
0
        public void RemoveNullBehaviourDoesNotThrowTest()
        {
            var ai = new UtilityAi();

            Assert.DoesNotThrow(() => ai.RemoveBehaviour((Behaviour)null));
        }
 protected override void ConfigureAi()
 {
     Ai = new UtilityAi(CharacterAi, AIs);
 }
Beispiel #21
0
        public void ConstructorTest()
        {
            var ai = new UtilityAi();

            Assert.IsNotNull(ai);
        }
Beispiel #22
0
        public void AddNullBehaviourReturnsFalseTest()
        {
            var ai = new UtilityAi();

            Assert.That(ai.AddBehaviour((Behaviour)null), Is.False);
        }
Beispiel #23
0
        public void AddStringBehaviourReturnsFalseWithNullCollectionTest()
        {
            var ai = new UtilityAi();

            Assert.That(ai.AddBehaviour("SomeBehaviour"), Is.False);
        }