public void ParallelNodeTest() { var root = new Parallel(); var stages = new Queue <string>(); var manager = new BehaviourTree(root); var conditionalA = new TestYieldConditionNode { PrintA = "AYield", PrintB = "A", Stages = stages, Conditional = s => s.A }; var conditionalB = new TestYieldConditionNode { PrintA = "BYield", PrintB = "B", Stages = stages, Conditional = s => s.B }; var conditionalC = new TestYieldConditionNode { PrintA = "CYield", PrintB = "C", Stages = stages, Conditional = s => s.C }; root.Children = new List <Node> { conditionalA, conditionalB, conditionalC }; foreach (var n in root.DepthFirstIterate()) { n.Initialize(); } Assert.AreEqual(0UL, manager.TickCount); // true true true => true stages.Enqueue("TICK"); manager.Update(new State { A = true, B = true, C = true }); Assert.AreEqual(Result.Unknown, manager.Result); Assert.AreEqual(0UL, manager.TickCount); var sequence = new List <string> { "TICK", "AYield", "BYield", "CYield" }; Assert.IsTrue(stages.SequenceEqual(sequence)); stages.Enqueue("TICK"); manager.Update(new State { A = true, B = true, C = true }); Assert.AreEqual(Result.Success, manager.Result); Assert.AreEqual(1UL, manager.TickCount); sequence.AddRange(new[] { "TICK", "A", "B", "C" }); Assert.IsTrue(stages.SequenceEqual(sequence)); // true false true => true stages.Enqueue("TICK"); manager.Update(new State { A = true, B = false, C = true }); Assert.AreEqual(Result.Unknown, manager.Result); Assert.AreEqual(1UL, manager.TickCount); sequence.AddRange(new[] { "TICK", "AYield", "BYield", "CYield" }); Assert.IsTrue(stages.SequenceEqual(sequence)); stages.Enqueue("TICK"); manager.Update(new State { A = true, B = false, C = true }); Assert.AreEqual(Result.Success, manager.Result); Assert.AreEqual(2UL, manager.TickCount); sequence.AddRange(new[] { "TICK", "A", "B", "C" }); Assert.IsTrue(stages.SequenceEqual(sequence)); // false false false => false stages.Enqueue("TICK"); manager.Update(new State { A = false, B = false, C = false }); Assert.AreEqual(Result.Unknown, manager.Result); Assert.AreEqual(2UL, manager.TickCount); sequence.AddRange(new[] { "TICK", "AYield", "BYield", "CYield" }); Assert.IsTrue(stages.SequenceEqual(sequence)); stages.Enqueue("TICK"); manager.Update(new State { A = false, B = false, C = false }); Assert.AreEqual(Result.Failure, manager.Result); Assert.AreEqual(3UL, manager.TickCount); sequence.AddRange(new[] { "TICK", "A", "B", "C" }); Assert.IsTrue(stages.SequenceEqual(sequence)); }