BAB
CBC
If you are at A, then the nearest elements are those Bs
Then the question is: Are the Cs considered to be the same distance from A (as the Bs).
In a chess game, a diagonal move is the same distance as a horizontal or vertical move.
Edit:
OK, so you check the 3 elements above, the 2 elements to the side, and the 3 elements below.
Of course, some of those might be off the board, so you have to check for that.
And if you don't find the X after all those checks, then you have to expand the search,
So I have a 2D array, at any element I want to find the nearest element marked 'X'
How should I go abouts searching for the nearest element? What would be the simplest implementation to do so? Any common techniques or known algorithms for finding the nearest element in a 2D array?
Any useful input will be greatly appreciated, thanks!