I want to create a random path in a 2d grid given a start point at the bottom row and an end point at the top of the row. I do not want the shortest path, or even the longest. Instead, I want a random path that can go up, down, left and right, but one that does not intersect itself.
I've been researching this question for days and cannot find anything that helps me solve the issue. I've read this questions Simplest way to generate a random path, however, the answer provided does not allow for the path to go backwards.
Some solutions I've thought of
- On every row select a random point, then travel to each of these points. This does not allow for moving backwards because I would continue to move up in the rows.
- Start the the beginning point, select a random point next, and so on until I reach the goal. This does not work because I can end up trapping myself and reaching a dead end.
How can I achieve this?