Search in sources :

Example 1 with BehaviorTreeRunner

use of org.terasology.logic.behavior.core.BehaviorTreeRunner in project Terasology by MovingBlocks.

the class CounterTest method assertRun.

private void assertRun(String tree, int executions, String expectedOutput) {
    Print.output = new StringBuilder();
    BehaviorNode node = treeBuilder.fromJson(tree);
    String json = treeBuilder.toJson(node);
    BehaviorNode n2 = treeBuilder.fromJson(json);
    String json2 = treeBuilder.toJson(n2);
    Assert.assertEquals(json, json2);
    Actor actor = new Actor(null);
    actor.setDelta(0.5f);
    BehaviorTreeRunner runner = new DefaultBehaviorTreeRunner(node, actor);
    for (int i = 0; i < executions; i++) {
        runner.step();
    }
    Assert.assertEquals(expectedOutput, Print.output.toString());
}
Also used : Actor(org.terasology.logic.behavior.core.Actor) BehaviorNode(org.terasology.logic.behavior.core.BehaviorNode) BehaviorTreeRunner(org.terasology.logic.behavior.core.BehaviorTreeRunner) Print(org.terasology.logic.behavior.actions.Print)

Aggregations

Print (org.terasology.logic.behavior.actions.Print)1 Actor (org.terasology.logic.behavior.core.Actor)1 BehaviorNode (org.terasology.logic.behavior.core.BehaviorNode)1 BehaviorTreeRunner (org.terasology.logic.behavior.core.BehaviorTreeRunner)1