How to create a random path?

I am looking for an algorithm that can generate something like what is in this image:

enter image description here

I read about drunk walking algorithms, but they don't seem to suit me what I need. I am not sure if I can achieve what I am looking for with a strongly modified drunken walking algorithm, or if I have to look for some other algorithm that I can interact with.

+8
algorithm graph-algorithm graphics
source share
1 answer

Since you want to avoid self-intersection, random walks will be hard to do right. You could easily paint yourself in the corner. I would suggest starting with one line segment that intersects the area, and then breaks up this line segment somewhere in the middle and shifts the midpoint by a random amount proportional to the length of the line segment. Repeat this process recursively for two new line segments. If you end up with a midpoint that causes one of two new line segments to cross an existing line segment, try a different midpoint. Stop the recursion when the segments of your line are short (however you want to define this).

+1
source share

All Articles