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 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 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); } }
public void AddNonExistentBehaviourReturnsFalseTest() { _aic.Clear(); var ai = new UtilityAi("testai", _aic); Assert.That(ai.AddBehaviour("some"), Is.False); }
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); }
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); }
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); }
public void AddStringBehaviourReturnsFalseWithNullCollectionTest() { var ai = new UtilityAi(); Assert.That(ai.AddBehaviour("SomeBehaviour"), Is.False); }
public void AddNullBehaviourReturnsFalseTest() { var ai = new UtilityAi(); Assert.That(ai.AddBehaviour((Behaviour)null), Is.False); }
protected override void ConfigureAi() { Ai = new UtilityAi(AiDefs.ToonAi, AIs); Ai.AddBehaviour(BehaviourDefs.LiveLong); Ai.AddBehaviour(BehaviourDefs.Prosper); }