This problem is from an a* pathfinding routine i am trying to write, i am reluctant to look at sample working versions so far because i want to learn from mistakes, though i realise its best not to reinvent the wheel!
Any thoughts are appreciated.
the problem is as follows
from a given current square on the search area i need to check the surrounding
adjacent squares for walkable or not walkable,, e.g.
0 = Not Walkable, 1 = walkable, 2 = current square (now on the closed list)
so my array 'area' that contains the portion i want to test may look like this
The current square (2) is always in the centre.
My problem is that is if any of the four central squares surrounding the current square are unwalkable the diagonal moves to the corners either side of the unwalkable node cannot be considered for the next current square as i am not allowing 'diagonal' moves around obstructions.
In the example this would be the 101 row, although they are walkable squares i cannot move to them from the current square without cutting across the corner of the unwalkable one.
So basically each time i need to check if any of these positions (x)are notwalkable x
and if so, ensure that the scores assigned to the nodes either side are not altered or are reset back to their previous state.
This is easy enough i suppose but when the current square is at the edge of the total search area it is giving me a headache because part of the area i would normally test is out of scope of the array.
so if it looked like this
with the final three positions i would like to check (***) being off the lower edge of the searcharea..... i am finding it hard to think how to 'ask' about the array position bottom left below the unwalkable node, without asking to look at contents of invalid and incorrect array elements,
It seems to be leading me to lots of messy IF statements is this just to be accepted in these cases?
the switch statement does not to really serve any better so any thoughts appreciated.
And i totally understand if this thread gets binned! i can't get a concise way of asking this question, and maybe thats also why i haven't yet come up with satisfactory answer!
the word processing knocked over my example with 'x's
i mean the top middle, left middle, right middle, and lower middle nodes.