Beispiel #1
0
        public void StartANewPlan(int startNodeIndex, int goalNodeIndex)
        {
            if (startNodeIndex == Node.kInvalidIndex || goalNodeIndex == Node.kInvalidIndex)
            {
                m_planStatus = Planner.ePlanStatus.kPlanFailed;
                return;
            }

            // Clear out the old data
            m_nodePool.Clear();
            m_openNodes.Clear();
            m_solution.Clear();
            m_expandedNodes.Clear();

            // Set the new data
            m_startNode = GetNode(startNodeIndex).Item;
            m_goalNode  = GetNode(goalNodeIndex).Item;

            // Initialize the success condition
            m_reachedGoalNodeSuccessCondition.Awake(m_goalNode);
            m_successCondition = m_reachedGoalNodeSuccessCondition;

            // Put the start node on the open list
            m_startNode.G      = 0.0f;
            m_startNode.H      = World.GetHCost(m_startNode.Index, m_goalNode.Index);
            m_startNode.F      = m_startNode.G + m_startNode.H;
            m_startNode.Parent = null;
            OpenNode(m_startNode);

            m_planStatus = ePlanStatus.kPlanning;
        }
        public void StartANewPlan(int startNodeIndex, int goalNodeIndex)
        {
			if ( startNodeIndex	== Node.kInvalidIndex || goalNodeIndex == Node.kInvalidIndex )
			{
				m_planStatus = Planner.ePlanStatus.kPlanFailed;
				return;
			}
			
            // Clear out the old data
            m_nodePool.Clear();
            m_openNodes.Clear();
            m_solution.Clear();
            m_expandedNodes.Clear();

            // Set the new data
            m_startNode = GetNode(startNodeIndex).Item;
            m_goalNode = GetNode(goalNodeIndex).Item;

            // Initialize the success condition
            m_reachedGoalNodeSuccessCondition.Awake(m_goalNode);
            m_successCondition = m_reachedGoalNodeSuccessCondition;

            // Put the start node on the open list
            m_startNode.G = 0.0f;
            m_startNode.H = World.GetHCost(m_startNode.Index, m_goalNode.Index);
            m_startNode.F = m_startNode.G + m_startNode.H;
            m_startNode.Parent = null;
            OpenNode(m_startNode);

            m_planStatus = ePlanStatus.kPlanning;
        }