示例#1
0
    /// <summary>
    /// Traverse the tree and checks all preconditions and/or adds actions to the plan.
    /// </summary>
    /// <param name="currentTask">The tasks that is currently checked.</param>
    private void Perform(Task currentTask)
    {
        // Check if the task is primitive.
        if (!currentTask.isPrimitiveTask)
        {
            // Check the preconditions of the abstract task
            if (currentTask.CheckPreconditions())
            {
                // Update the predicted world state.

                // Traverse all subtasks.
                for (int i = 0; i < currentTask.subtasks.Count; i++)
                {
                    Perform(currentTask.subtasks[i]);
                }
            }
        }
        else
        {
            // Add the action of the primitive task to the plan.
            plan.AddActionToPlan(currentTask.action);
        }
    }