Exemple #1
0
 //used for debugging
 void printSolutionRecusively(AIAgentAStarSearchNode currentNode)
 {
     if (currentNode != null)
     {
         printSolutionRecusively(currentNode.getParentNode());
         polygonFinalCount++;
     }
 }
Exemple #2
0
 /*
  * addFinalsolutionPolygonsPostOrder method is a recusive method that will look at the parent of each node passed in until
  *      the node passed in is null, then it will add each Node's polygon to the finalSolutionArray in pre order
  *      from start until end
  * Parameter:	(AIAgentAStarSearchNode)currentNode is the node that needs to be checked and then have its parent passed
  *              (ref int)counter is the current count of polygons in the FinalSolution array used to access the next index
  * Return:	none
  */
 void addFinalSolutionPolygonsPreOrder(AIAgentAStarSearchNode currentNode, ref int counter)
 {
     if (currentNode != null)
     {
         finalSolutionArray [counter] = currentNode.getPolygon();
         counter++;
         addFinalSolutionPolygonsPreOrder(currentNode.getParentNode(), ref counter);
     }
 }
 //used for debugging
 void printSolutionRecusively(AIAgentAStarSearchNode currentNode)
 {
     if (currentNode != null)
     {
         printSolutionRecusively(currentNode.getParentNode());
         Debug.Log(Time.realtimeSinceStartup + " id = " + currentNode.getPolygon().getID());
         polygonFinalCount++;
     }
 }
Exemple #4
0
 /*
  * addFinalsolutionPolygons method is a recusive method that will look at the parent of each node passed in until
  *      the node passed in is null, then it will add each Node's polygon to the finalSolutionArray in order
  *      from start until end
  * Parameter:	(AIAgentAStarSearchNode)currentNode is the node that needs to be checked and then have its parent passed
  *              (ref int)counter is the current count of polygons in the FinalSolution array used to access the next index
  * Return:	none
  */
 void addFinalSolutionPolygons(AIAgentAStarSearchNode currentNode, ref int counter)
 {
     if (currentNode != null)
     {
         addFinalSolutionPolygons(currentNode.getParentNode(), ref counter);
         finalSolutionArray [counter] = currentNode.getPolygon();
         if (counter != 0)
         {
             finalPathCost += (finalSolutionArray[counter].getCenterVector() - finalSolutionArray[counter - 1].getCenterVector()).magnitude;
         }
         counter++;
     }
 }
    /* enqueue adds a node to the front of this list
     * Parameter: (AIAgentAStarSearchNode) nodeToAdd is the node to be added to the front of the list
     * Return: none
     */
    public void enqueue(AIAgentAStarSearchNode nodeToAdd)
    {
        AIAgentAStarSearchNode newNode = new AIAgentAStarSearchNode(nodeToAdd.getPolygon(), nodeToAdd.getParentNode(), nodeToAdd.getGFromStartingNode(), goalPosition);

        newNode.setNextNode(frontOfList);
        frontOfList = newNode;
    }