Advertisement

Pathfinding, need feedback

Started by April 30, 2020 05:52 PM
109 comments, last by Calin 4 years, 6 months ago

SillyCow said:
DFS, try BFS…

I almost have it figured already. I`m sure the system is already there and has a name.

My project`s facebook page is “DreamLand Page”

NikiTo said:

Calin said:
I should know the author or at least the article reference should be made by someone that I know/familiar with to some degree.

Because gov lies to us. Knowledge must be handed from hand to hand, personally in person. OOP is an evil corp.

Are you making fun of me? (Sorry NikiTo I ignored you in this thread)

My project`s facebook page is “DreamLand Page”

Advertisement

Calin said:
(Sorry NikiTo I ignored you in this thread)

Because i am an agent of the gov, right?

Because i am an agent of the gov, right?

Do you have a badge?

If you have a badge you`re officially agent of the govment.

My project`s facebook page is “DreamLand Page”

Because i am an agent of the gov, right?

Do you have a badge?

My project`s facebook page is “DreamLand Page”

Call me agent 00111!

Advertisement

agent 00111 lets keep this thread on topic or I get shut down.

My project`s facebook page is “DreamLand Page”

Calin said:

agent 00111 lets keep this thread on topic or I get shut down.

What is the topic of this thread?

almost have it finished

the final step is to compute the weight by adding parent count and square root distance to Destination/End

int FindParentTrack(int BestNodeParent, int Startx, int Startz)
{
     bool keepgoing = true;
     int pathlength = 0;
     
     PathTile Tile;
     Tile.Parent= BestNodeParent;
     while(keepgoing)
     {
      pathlength++;
       

       
      if((TrunkList[Tile.Parent].x != Startx)&&(TrunkList[Tile.Parent].z != Startz))
      {
       
       StringCchPrintfA(IGmessage,1024,"Tile parent %d, iteration %d ",Tile.Parent, pathlength);
       MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
       Tile.Parent = TrunkList[Tile.Parent].Parent;
      }
      else
      {
      StringCchPrintfA(IGmessage,1024,"exiting, last parent  %d ",Tile.Parent);
      MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
       keepgoing = false;
      }
       
     }
     return pathlength;
}

void FindPath(int Startx, int Startz, int Endx, int Endz)
{
 
for(int i =0; i < 50; i++)
{

 TrunkList[i].cold = false;
 TrunkList[i].weight = 10;
}
 
 
bool exists = false;
bool exit = false;
bool firstrun = true;
PathTile BestNode;
AddGroup(0);

while(!exit)
{
 

 if(firstrun)
 {
    TrunkListCount++;
    TrunkList[TrunkListCount].x =  Startx;
    TrunkList[TrunkListCount].z =  Startz;
    TrunkList[TrunkListCount].index = TrunkListCount;
  firstrun = false;
 }
   
 
 int bestweight = 1000;
 int indexofbw = -1;
 for(int i =0; i < TrunkListCount+1; i ++)
 {
  if(!TrunkList[i].cold)
  {
   if(TrunkList[i].weight < bestweight)
    {
     bestweight = TrunkList[i].weight;
     indexofbw = i;
    }
  }
 
 }
   
  BestNode.x = TrunkList[indexofbw].x;
  BestNode.z = TrunkList[indexofbw].z;
  BestNode.index = TrunkList[indexofbw].index;
  BestNode.Parent = TrunkList[indexofbw].Parent;
  StringCchPrintfA(IGmessage,1024,"best node x %d z %d",BestNode.x,BestNode.z);
    MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);
 
 if((BestNode.x != Endx)||(BestNode.z != Endz))
 {
  int x = BestNode.x;
  int z = BestNode.z;
   
  if(NodeCoord(x,z+1,1).access)//n
  {
   exists = false;
   for(int i =0; i < TrunkListCount; i++)
   {
    if((TrunkList[i].x == NodeCoord(x,z+1,2).x)&amp;amp;&amp;amp;(TrunkList[i].z == NodeCoord(x,z+1,3).z))
    {
     exists = true;
    }
     
   }
   if(!exists)
   {
     
    TrunkListCount++;
    TrunkList[TrunkListCount].x =  NodeCoord(x,z+1,4).x;
    TrunkList[TrunkListCount].z =  NodeCoord(x,z+1,5).z;
    TrunkList[TrunkListCount].index = TrunkListCount;
    TrunkList[TrunkListCount].Parent = BestNode.index;
    int ParentCount = FindParentTrack(BestNode.index,Startx, Startz);
    //TrunkList[TrunkListCount].weight =  

     
    StringCchPrintfA(IGmessage,1024,"add tile x %d z %d i %d parent count %d",TrunkList[TrunkListCount].x,TrunkList[TrunkListCount].z,TrunkListCount, ParentCount );
    MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);

   
     
     
   }
  }
  if(NodeCoord(x+1,z+1,7).access)//ne
  {
   exists = false;
   for(int i =0; i < TrunkListCount; i++)
   {
    if((TrunkList[i].x == NodeCoord(x+1,z+1,8).x)&amp;amp;&amp;amp;(TrunkList[i].z == NodeCoord(x+1,z+1,9).z))
    {
     exists = true;
    }
     
   }
   if(!exists)
   {
    TrunkListCount++;
    TrunkList[TrunkListCount].x =  NodeCoord(x+1,z+1,10).x;
    TrunkList[TrunkListCount].z =  NodeCoord(x+1,z+1,11).z;
    TrunkList[TrunkListCount].index = TrunkListCount;
    TrunkList[TrunkListCount].Parent = BestNode.index;
    int ParentCount = FindParentTrack(BestNode.index,Startx, Startz);
     
    StringCchPrintfA(IGmessage,1024,"add tile x %d z %d i %d parent count %d",TrunkList[TrunkListCount].x,TrunkList[TrunkListCount].z,TrunkListCount, ParentCount );
    MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);

     

     
     
   }    
  }
  if(NodeCoord(x+1,z,13).access)//e
  {
   exists = false;
   for(int i =0; i < TrunkListCount; i++)
   {
    if((TrunkList[i].x == NodeCoord(x+1,z,14).x)&amp;amp;&amp;amp;(TrunkList[i].z == NodeCoord(x+1,z,15).z))
    {
     exists = true;
    }
     
   }
   if(!exists)
   {
    TrunkListCount++;
    TrunkList[TrunkListCount].x =  NodeCoord(x+1,z,16).x;
    TrunkList[TrunkListCount].z =  NodeCoord(x+1,z,17).z;
    TrunkList[TrunkListCount].index = TrunkListCount;
    TrunkList[TrunkListCount].Parent = BestNode.index;
    int ParentCount = FindParentTrack(BestNode.index,Startx, Startz);



    StringCchPrintfA(IGmessage,1024,"add tile x %d z %d i %d parent count %d",TrunkList[TrunkListCount].x,TrunkList[TrunkListCount].z,TrunkListCount, ParentCount );
    MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);

     
     
     
   }  
  }
  if(NodeCoord(x+1,z-1,19).access)//se
  {
   exists = false;
   for(int i =0; i < TrunkListCount; i++)
   {
    if((TrunkList[i].x == NodeCoord(x+1,z-1,20).x)&amp;amp;&amp;amp;(TrunkList[i].z == NodeCoord(x+1,z-1,21).z))
    {
     exists = true;
    }
     
   }
   if(!exists)
   {
    TrunkListCount++;
    TrunkList[TrunkListCount].x =  NodeCoord(x+1,z-1,22).x;
    TrunkList[TrunkListCount].z =  NodeCoord(x+1,z-1,23).z;
    TrunkList[TrunkListCount].index = TrunkListCount;
    TrunkList[TrunkListCount].Parent = BestNode.index;
    int ParentCount = FindParentTrack(BestNode.index,Startx, Startz);

   
    StringCchPrintfA(IGmessage,1024,"add tile x %d z %d i %d parent count %d",TrunkList[TrunkListCount].x,TrunkList[TrunkListCount].z,TrunkListCount, ParentCount );
    MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);


     
     
   }   }
  if(NodeCoord(x,z-1,25).access)//s
  {
   exists = false;
   for(int i =0; i < TrunkListCount; i++)
   {
    if((TrunkList[i].x == NodeCoord(x,z-1,26).x)&amp;amp;&amp;amp;(TrunkList[i].z == NodeCoord(x,z-1,27).z))
    {
     exists = true;
    }
     
   }
   if(!exists)
   {
    TrunkListCount++;
    TrunkList[TrunkListCount].x =  NodeCoord(x,z-1,28).x;
    TrunkList[TrunkListCount].z =  NodeCoord(x,z-1,29).z;  
    TrunkList[TrunkListCount].index = TrunkListCount;
    TrunkList[TrunkListCount].Parent = BestNode.index;
    int ParentCount = FindParentTrack(BestNode.index,Startx, Startz);
     
     
    StringCchPrintfA(IGmessage,1024,"add tile x %d z %d i %d parent count %d",TrunkList[TrunkListCount].x,TrunkList[TrunkListCount].z,TrunkListCount, ParentCount );
    MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);

     
   }    
  }
  if(NodeCoord(x-1,z-1,31).access)//sw
  {
   exists = false;
   for(int i =0; i < TrunkListCount; i++)
   {
    if((TrunkList[i].x == NodeCoord(x-1,z-1,32).x)&amp;amp;&amp;amp;(TrunkList[i].z == NodeCoord(x-1,z-1,33).z))
    {
     exists = true;
    }
     
   }
   if(!exists)
   {
    TrunkListCount++;
    TrunkList[TrunkListCount].x =  NodeCoord(x-1,z-1,34).x;
    TrunkList[TrunkListCount].z =  NodeCoord(x-1,z-1,35).z;
    TrunkList[TrunkListCount].index = TrunkListCount;
    TrunkList[TrunkListCount].Parent = BestNode.index;
    int ParentCount = FindParentTrack(BestNode.index,Startx, Startz);

    StringCchPrintfA(IGmessage,1024,"add tile x %d z %d i %d parent count %d",TrunkList[TrunkListCount].x,TrunkList[TrunkListCount].z,TrunkListCount, ParentCount );
    MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);


   
   } }
  if(NodeCoord(x-1,z,37).access)//w
  {
   exists = false;
   for(int i =0; i < TrunkListCount; i++)
   {
    if((TrunkList[i].x == NodeCoord(x-1,z,38).x)&amp;amp;&amp;amp;(TrunkList[i].z == NodeCoord(x-1,z,39).z))
    {
     exists = true;
    }
     
   }
   if(!exists)
   {
    TrunkListCount++;
    TrunkList[TrunkListCount].x =  NodeCoord(x-1,z,40).x;
    TrunkList[TrunkListCount].z =  NodeCoord(x-1,z,41).z;
    TrunkList[TrunkListCount].index = TrunkListCount;
    TrunkList[TrunkListCount].Parent = BestNode.index;
    int ParentCount = FindParentTrack(BestNode.index,Startx, Startz);


    StringCchPrintfA(IGmessage,1024,"add tile x %d z %d i %d parent count %d",TrunkList[TrunkListCount].x,TrunkList[TrunkListCount].z,TrunkListCount, ParentCount );
    MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);

   }}
  if(NodeCoord(x-1,z+1,43).access)//nw
  {
   exists = false;
   for(int i =0; i < TrunkListCount; i++)
   {
    if((TrunkList[i].x == NodeCoord(x-1,z+1,44).x)&amp;amp;&amp;amp;(TrunkList[i].z == NodeCoord(x-1,z+1,45).z))
    {
     exists = true;
    }
     
   }
   if(!exists)
   {
    TrunkListCount++;
    TrunkList[TrunkListCount].x =  NodeCoord(x-1,z+1,46).x;
    TrunkList[TrunkListCount].z =  NodeCoord(x-1,z+1,47).z;
    TrunkList[TrunkListCount].index = TrunkListCount;
    TrunkList[TrunkListCount].Parent = BestNode.index;
    int ParentCount = FindParentTrack(BestNode.index,Startx, Startz);


    StringCchPrintfA(IGmessage,1024,"add tile x %d z %d i %d parent count %d",TrunkList[TrunkListCount].x,TrunkList[TrunkListCount].z,TrunkListCount, ParentCount );
    MessageBox(NULL, IGmessage, "Textures.exe", MB_OK);

     
     
   }   }
  TrunkList[BestNode.index].cold = true;
  //PrintVariable(0,
 }
 else
 {
  exit = true;
 }
}



}

My project`s facebook page is “DreamLand Page”

Calin said:
for(int i =0; i < TrunkListCount; i++)

Slowest path finding algorithm i've ever seen.

Slowest path finding algorithm i've ever seen.

Slowest path finding algorithm i've ever seen.

Slowest path finding algorithm i've ever seen.

Slowest path finding algorithm i've ever seen.

Slowest path finding algorithm i've ever seen.

Slowest path finding algorithm i've ever seen.

Slowest path finding algorithm i've ever seen.

This topic is closed to new replies.

Advertisement