I want to create a random path in a 2D grid from a starting point in the bottom row and from an end point to the top of the row. I do not want the shortest path, or even the longest. Just a random path that can go up, down, left and right.
I have been researching this issue for days and can not find anything that can help solve the problem. I have read this question. This is the easiest way to generate a random path, but the answer provided does not allow the path back.
Some solutions I've thought of
- On each line, select a random point, then go to each of these points. This does not allow to go back because I would continue to climb the rows.
- Start at the starting point, select a random point, and so on until I reach the goal. It does not work because I can end up trapping and stalling.
How can I achieve this goal?