City generator: rivers
River meandering
(Originally posted on Tumblr on 2025-02-15)
workin on rivers. different meander parameters
algorithm:
- choose a random border polygon
- set the goal as any polygon along the opposite border
- find all neighbors of the current polygon
- choose one of those neighbors, biased by distance (closer to the goal is more likely). the river_meander parameter loosens this bias.
- follow this path until the goal edge is reached
usually there's like 3-5 polygons in a list of neighbors. I'm using random.expovariate(river_meander) for random choice, normalized by length. I figure an offset might make the parameter more effective but I'm fine how it is now, just use really small numbers if you need crazy crazy rivers.
canvas size is only the display size.
I plan on making river curves soon but that's also pretty hard for my non-geometric brain. who knows how long I'm going to stick with this project