public Planner(PlanningTree root, GameObject agent, NavMeshAgent agentNav, WorldState ws) { this.root = root; this.agent = agent; this.agentNav = agentNav; this.ws = ws; }
private int runPlanFromNode(PlanningTree node) { // Debug.Log(node.task); if (!preconditionsMet(node.task)) { return(-1); } int result = -1; if (node.children.Count == 0) { return(taskExecutor(node.task)); } for (int i = 0; i < node.children.Count; i++) { result = runPlanFromNode(node.children[i]); if (result == 1) { executing = false; return(1); } } return(result); }
private void initializePlanningTree() { PlanningTree root = new PlanningTree(null, "BeAwesome"); root.addChild(new PlanningTree(root, "Teleport")); root.addChild(new PlanningTree(root, "AvoidEnemy")); root.addChild(new PlanningTree(root, "CollectItems")); PlanningTree curNode = root.children[1]; curNode.addChild(new PlanningTree(curNode, "StayInPosition")); curNode.addChild(new PlanningTree(curNode, "HideInAlcove")); currentNode = root; }
public void addChild(PlanningTree node) { children.Add(node); }
public void addChildToPos(int childPos, PlanningTree node) { children.Insert(childPos, node); }
public PlanningTree(PlanningTree parent, string task) { this.parent = parent; this.task = task; }