I noticed Wezu was making a game that involved pathfinding using a grid layout and decided to make a demo that supports my suggestion in the showcase forum.
This code is in no way perfect, because it is not complete! At the same time, it is not flawed either. This demo is of a raw foundation for creating a really good grid base pathfinding AI.
Of course there is more than one way to do it, so someone else might take an entirely different approach. I felt coding it this way would make it really easy for anyone to understand it; plus make it easier to upgrade later.
If anyone does take this code and modify or perfect it into useable code for a commercial quality game, please let me know; I would love to have a copy of that.
If I had the time, I would do it myself.
Oh well, knock yourselves out.
http://www.freefilehosting.net/pathaigridbase
PS,
I might have typed in some incorrect position values, based on the Blender model file in the data folder. I haven’t found any errors, but if you work on this code and all of a sudden the Rat doesn’t move right, I might have an incorrect center position value for a tile.
I did not leave many notes in the source code, since it pretty much explains itself.