Пример #1
0
    public Queue <GOAP_BaseAction> createPlan(List <GOAP_BaseAction> possibleActions, Dictionary <string, int> goal, GOAP_WorldStates worldStates)
    {
        List <Node>      nodes = new List <Node>();
        GOAP_WorldStates currentWorldStates = GOAP_World.getWorldInstance().getWorldStates();
        Node             root = new Node(null, 0, null, currentWorldStates.getStates());

        // Generate tree and determine if there is a possible plan
        if (createTree(root, nodes, possibleActions, goal))
        {
            // Get the cheapest possible path to the goal and return the last node in that branch.
            Node cheapest = getCheapestPath(nodes);

            // Once we have the cheapest node, work backwards on the branch to add each actions that achieve the goal
            return(getPlan(cheapest));
        }
        else
        {
            Debug.Log("Planner failed to obtain plan!");

            return(null);
        }
    }
Пример #2
0
 static GOAP_World()
 {
     worldStates = new GOAP_WorldStates();
 }