GMS 2Generating a line from A to B in a grid, with random variation

MagnumVulcanos

Member
Hello, I am trying to generate a path from a point in a grid to another, I am trying to do this in a 100x100 ds_grid in a way that the player won't be able to detecta s a stright line or perfect curve, to do this I need to "draw" a line from one center side of the map to another. This will be used to generate rivers and roads. The results could look something like this:

The lines always start and end at one of 4 points, and should be random.
Problem is, I don't even know what to look for exactly, the function that makes this should have a name, but I don't know what it's called.
I've looked up how to generate rivers in 2d grids, and found tips on 2d world generation, but without luck.
Any help would be appreciated, especially pointers to an explanation, even if they are written in another programming langauge.

NightFrost

Member
Is your terrain a flat plane? If it had elevation changes (generated with some algorithm) rivers would be a matter of having them run to neighbouring cell that has the lowest elevation. But just for randomly generated river meandering... if you didn't have set endpoint, you could modify something like drunkard walk, weighted towards given direction. But since you want it to run from given point A to given point B, maybe a bezier curve with a number of points derived from distance between A and B, their positions randomly offset from line between A and B.

MagnumVulcanos

Member
bezier curve
YES
My terrain is a plane, seen from above.
I thought of creating varyous lines that go from start to end, then interpolating those lines and separating them into 10 lines, and randomly adding or substracting a value to each, so that I would get a "random" line between A and B. A bezier curve is a good start to something that may be better, thanks for the info!