I don't think it matters too much if you just set everything to 100, just depends on how you check the walls when calculating the path. Like, it might be safer to just check a separate map array for collision, rather than relying on a set value for a wall. Once the path calculation is complete, the walls should all be still set to 100.
There is no starting location
- because it's such a small map, you might as well solve the path for every location, the flood fill system will do that - basically the path array will be filled completely, so you could start at any location and find the destination. I would just keep setting the array for the player position to 0, run through the routine once or twice, and do that each loop - and there would be a constant pathway to the player that updates automatically. If you set a map location to have no wall, like opening a door, then it would even allow for that.
When scanning the array, I'd do something like this:
For x=1 to 10
For z=1 to 10
If map[x,z]<>wall
near=100
If path[x-1,z] < near then near=path[x-1,z]
If path[x+1,z] < near then near=path[x+1,z]
If path[x,z-1] < near then near=path[x,z-1]
If path[x,z+1] < near then near=path[x,z+1]
path[x,z]=near+1
Endif
Next z
Next x
But then change up the order that the array is scanned, like...
For x=1 to 10
For z=1 to 10
...
Next z
Next x
For z=1 to 10
For x=1 to 10
...
Next x
Next z
For x=10 to 1
For z=10 to 1
...
Next z
Next x
For z=10 to 1
For x=10 to 1
...
Next x
Next z
So it goes vertical stripes, horizontal stripes, reverse vertical, reverse horizontal. This is not 100% vital, what it actually does is improves the functions ability to calculate corridors quickly, like a long line of blank map, no matter how long, would be filled with the path data within 1 set of passes. If you use another variable to step through, then you could use a counter to decide which direction, and just set X and Z depending on that, that's one way to avoid repeating the same path code 4 times.
I have done this with a dungeon game project, it turned out to be too basic for a 3D dungeon crawler - but for a top down maze it should be ideal. I'll see if I can knock up a little example of this for you.
I am the one who knocks...