A possible solution outline:
-
Create a Stack to hold grid positions - Stack<Position>
-
Check that the starting position is not blocked!
-
Set the current position to the starting position and push each immediate neighbor on the stack provided that neighbor is not already marked.
-
While the current position is not the finish position and the stack is not empty
-
pop the top position off the stack
-
If the position is not marked, make it the current position, mark it and add its unmarked neighbors to the stack.
-
-
If current is NOT the finish position, there is no path from the start to the finish.