public void CooldownTest(float cooldown) { var action = new ActionSequence(); for (int i = 0; i < 10; i++) { action.Actions.Add(new MockAction()); } int milliSeconds = (int)(1000 * cooldown) + 1; action.Cooldown = cooldown; action.Execute(_customContext); Assert.AreEqual(ActionStatus.Success, action.ActionStatus); Assert.AreEqual(true, action.InCooldown); action.Execute(_customContext); Assert.AreEqual(ActionStatus.Failure, action.ActionStatus); Thread.Sleep(milliSeconds); Assert.AreEqual(false, action.InCooldown); action.Execute(_customContext); Assert.AreEqual(ActionStatus.Success, action.ActionStatus); Assert.AreEqual(true, action.InCooldown); }
// Update is called once per frame void Update() { //makes sure the goals are not being added to ResetAllGoals(); //function to check health CheckHealth(); // if the AI is close to the power up. update the utility of the AI if (_agentSenses.GetObjectInViewByName("Power Up")) { TheAI.UpdateGoalValue(AIGoals.PowerUp, 10); } else { // if not update the Utility of the Ai again for a differnt goals CheckEnemyflag(); TheAI.UpdateGoalValue(AIGoals.PowerUp, -10); } //final update depending on what flags they have captured if (!NeedsHealth) { CheckEnemyflag(); } //depending on the utility value of each of the actions pick one that satifys the highest goal ActionSequence CurrentAction = TheAI.ChooseAction(); CurrentAction.Execute(this); Startcheck = true; }
public void EnsureUpdatableActionsExecutedTest() { var action = new ActionSequence(); for (int i = 0; i < 10; i++) { action.Actions.Add(new UpdatingAction(UpdateIterations)); } for (int i = 0; i < 10; i++) { Assert.AreEqual(ActionStatus.Idle, action.Actions[i].ActionStatus); } int count = 0; do { count++; action.Execute(_customContext); } while(action.ActionStatus == ActionStatus.Running); Assert.AreEqual(UpdateIterations, count); Assert.AreEqual(ActionStatus.Success, action.ActionStatus); for (int i = 0; i < 10; i++) { Assert.AreEqual(ActionStatus.Success, action.Actions[i].ActionStatus); } }
public void FailureConditionTest() { var actionSequence = new ActionSequence(); for (int i = 0; i < 10; i++) { actionSequence.Actions.Add(new UpdatingAction(UpdateIterations)); } var newAction = _aiConstructor.Actions.Create(TestActionDefs.FailingAction); actionSequence.Actions.Add(newAction); for (int i = 0; i < 11; i++) { Assert.AreEqual(ActionStatus.Idle, actionSequence.Actions[i].ActionStatus); } int count = 0; do { count++; actionSequence.Execute(_customContext); } while(actionSequence.ActionStatus == ActionStatus.Running); Assert.AreEqual(UpdateIterations, count); Assert.AreEqual(ActionStatus.Failure, actionSequence.ActionStatus); Assert.AreEqual(ActionStatus.Failure, actionSequence.Actions[10].ActionStatus); for (int i = 0; i < 10; i++) { Assert.AreEqual(ActionStatus.Success, actionSequence.Actions[i].ActionStatus); } }
public void EnsureActionsExecutedTest() { var action = new ActionSequence(); for (int i = 0; i < 10; i++) { action.Actions.Add(new MockAction()); } for (int i = 0; i < 10; i++) { Assert.AreEqual(ActionStatus.Idle, action.Actions[i].ActionStatus); } action.Execute(_customContext); Assert.AreEqual(ActionStatus.Success, action.ActionStatus); for (int i = 0; i < 10; i++) { Assert.AreEqual(ActionStatus.Success, action.Actions[i].ActionStatus); } Assert.AreEqual(ActionStatus.Success, action.ActionStatus); }