public void ConditionMultiple() { var root = new SequenceNode(); var succ = new TaskSuccessNode(); succ.AppendDecorator(new ConditionSuccess()); succ.AppendDecorator(new ConditionFail()); root.Append(succ); root.Append(new TaskFailureNode()); //expected condition false Assert.That(root.Run(null), Is.EqualTo(NodeState.Failure)); Assert.That(succ.executed, Is.EqualTo(false)); }
public void ConditionFailSingle() { var root = new SequenceNode(); var succ = new TaskSuccessNode(); succ.AppendDecorator(new ConditionFail()); root.Append(succ); root.Append(new TaskFailureNode()); Assert.That(root.Run(null), Is.EqualTo(NodeState.Failure)); //should skip the success condition Assert.That(succ.executed, Is.EqualTo(false)); }
public void SetValueAfterExecution_Green() { var root = new SequenceNode(); var bt = new BT.BT(root); var suc = new TaskSuccessNode(); suc.AppendDecorator(new SetValueAfterExecution("foo", () => 10)); //for example set target position root.Append(suc); bt.Run(); Assert.That(bt.BlackBoard.ReadValue <int>("foo"), Is.EqualTo(10)); }
public void Tag_Green() { var root = new SequenceNode(); var suc = new TaskSuccessNode(); suc.AppendDecorator(new Tag("foo")); root.Append(suc); var bt = new BT.BT(root); bt.Run(); Assert.That(bt.GetActiveTag(), Is.EqualTo("foo")); }
public void WriteOnFailure_Red() { var root = new SequenceNode(); var suc = new TaskSuccessNode(); suc.AppendDecorator(new SetValueOnFail("foo", () => 1)); root.Append(suc); BT.BT bt = new BT.BT(root); bt.BlackBoard.SetValue("foo", 0); Assert.That(bt.BlackBoard.ReadValue <int>("foo"), Is.EqualTo(0)); bt.Run(); Assert.That(bt.BlackBoard.ReadValue <int>("foo"), Is.EqualTo(0)); }
public void ConditionConstant_Red() { var root = new SequenceNode(); var bt = new BT.BT(root); bt.BlackBoard.SetValue("foo", 10); var suc = new TaskSuccessNode(); suc.AppendDecorator(new BlackBoardConstantCondition <IntCondition, int>("foo", 10, ConditionType.Equal)); //for example set target position root.Append(suc); bt.Run(); Assert.That(suc.executed, Is.Not.EqualTo(false)); }
public void ConditionSuccessSingle() { var root = new SequenceNode(); var succ = new TaskSuccessNode(); succ.AppendDecorator(new ConditionSuccess()); root.Append(succ); var fail = new TaskFailureNode(); fail.AppendDecorator(new ConditionFail()); root.Append(fail); Assert.That(root.Run(null), Is.EqualTo(NodeState.Success)); //should skip the fail node Assert.That(succ.executed, Is.EqualTo(true)); Assert.That(fail.executed, Is.EqualTo(false)); }