I'm trying to generate a random path on a 2D grid given that:
- The width and height of the grid are given
- The length of the path to generate is given
- The path can't move "back"
- The path starts from a random point at height 0 and ends at a random point at max height
- A path segment cannot "touch" with a path segment that is at its height - 1 that is not the latest generated segment of the previous height
This is what two paths generated from the parameters {Width:11, Length:17, PathLength:30} would look like:
and this is an example of a path that should not be generated:
The result of the algorithm should be a list of value pairs such as this: (8,6) in any order, which indicates the segments of the path. I've been trying to solve this problem for a while, but I have problems understanding how to make this have a given length. If the given length was not a requirement I could just generate it with a nested for cycle and some rules. Please help!