# Creating Pathfinding Tables... how?

This topic is 4254 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am having a hard time visualising how pathfinding works. I have read several tutorials on the subject over and over, and although I understand the concept behind pathfinding, I am having a hard time putting it into something workable. Let's take a simple 2d screen size, of 800x600. Lets say I want to divide the screen into blocks of 10x10. So that would be a grid of 80x60. I know each block would have to somhow contain the weight it is to go from itself to the other 8 blocks that surrond it, and infinity for blocks that aren't passable. So the question is, how do I track all this? Do I manually write out 4,800 arrays, or tables, or what is the best way to create the tables. Lets say I get into adding walls and stuff, obviously I will set the tiles weight to infinity, but then how does the pathfinding system know that this tile is no longer the origonal weight, but the new weight? I won't even get into a 3d environment, where you can go from upstairs, inside and out of building, etc. Please help me understand. BUnzaga

##### Share on other sites
If you have the cost to move into a given block, then you only have 4800 values to store. Then, read about A* to find the optimal path from one point to another. Google A STAR to find lots of info, or search this forum, where there are gobs of links and information.

##### Share on other sites
Your screen has 800x600 = 480,000 pixels on it! Do you write out the color for every pixel? These pathfinding values are no different.

##### Share on other sites
- "So the question is, how do I track all this? Do I manually write out 4,800 arrays, or tables, or what is the best way to create the tables."

Usually the cost of entering a square is the same regardless of which side you come from, so you only need 4800 values, not 4800x8 values.

- "Lets say I get into adding walls and stuff, obviously I will set the tiles weight to infinity, but then how does the pathfinding system know that this tile is no longer the origonal weight, but the new weight?"

A wall is something you add once. So you set the weight of that square to the appropriate value (infinity or whatever). It's just a value, no magic there, no need to remember old or new values.

- "I won't even get into a 3d environment, where you can go from upstairs, inside and out of building, etc."

It's no different in principle, just more adjacent squares for each one.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633731
• Total Posts
3013582
×