| |
|
||||
|
|
PathfindingI covered the subject of pathfinding in games in an recent article for PC Extreme some time ago. For anyone that is interested, here are the two demo programs I wrote to go with it: pathfinder1.zip and pathfinder2.zip.
I don't want to repeat the article here, but basically, you divide the map up into squares. For each square you work out: F = G + H G is the number of steps you have taken from the start (number in bottom left corner in the diagram), and H is the number of steps to the destination ignoring any obstructions (bottom right corner in the diagram). F is the sum and the path is the squares with the lowest F value. Try the programs and see for yourself. It's a fascinating subject.
|