Making 2d world generation deterministic

I'm attempting to redesign a world generation system to make it deterministic, but im having trouble finding a way to achieve my desired terrain style. Originally how terrain gen worked was that you'd loop through the width of the world and start by randomly choosing a landform (mountain, hill, flatland) to base terrain height from, and the landform would last a certain amount of blocks (I had each landform set to be 50-200 blocks wide) Im not sure on how to make this logic deterministic though. I explored using perlin noise as an option but i have no idea where to start
13 Replies
mg
mg6mo ago
what do you mean by deterministic?
Moneylover3246
Moneylover3246OP6mo ago
as in for a given seed you'd receive the same outcome
mg
mg6mo ago
that's just a matter of setting that seed in your random number generator
Moneylover3246
Moneylover3246OP6mo ago
i guess im using the wrong word i need the terrain type for a given block to be independent so i can scale the world to be infinite
mg
mg6mo ago
so is the issue with the generation being deterministic or with it not scaling past a certain finite size?
Moneylover3246
Moneylover3246OP6mo ago
well the generation needs to be deterministic, but yea the bigger issue is the fact that the old generation system cant scale
mg
mg6mo ago
well as far as being reproducible with the same seed goes, you just have to pass that seed to whatever random number generator you're using. in the case of System.Random that just means creating a new Random(seed) for scaling i'm not sure. i don't do game dev and i'd probably need more details on how your generator works and why it doesn't scale as-is
Moneylover3246
Moneylover3246OP6mo ago
well the world generates all at once as of now i need to be able to split generation into chunks, but with this implementation it can't happen since the properties of a generated block depend on a continuous generation model if that makes sense sticking to terrain an example would be the fact that for a given block we need to know which landform to assign it (or if we need to give it a new one), but we can't because the landform length is information we made for a previous block
mg
mg6mo ago
yeah, i've never dabbled in any kind of procedural generation so i can't offer much help in that regard
Moneylover3246
Moneylover3246OP6mo ago
it's unfortunate too because i can't find anyone on the web whos dealt with my particular situation i know typically for 2d procedural generation you'd just use a perlin noise graph and directly map that to terrain height but that's not what im going for
Stefanidze
Stefanidze6mo ago
Well how would you imagine it not doing so? I think you should store the noisemap somewhere and then generate chunks based on that and the coords of the chunk being generated You either fill the map with "ghost chunks" that ask the code to be generated when the player enters proximity Or the player creates the "ghost chunks" in places within their render distance and they ask the generator to be generated on creation
Poller
Poller6mo ago
you could seed each chunk with a combination of your initial seed and the chunk coordinates. this way it doesnt matter in what order its generated. but you need to pay a lot of attention about generation for chunk borders. otherwise if you need to generate a specific chunk you need to generate all previous one 'hidden' like @Stefanidze said
Stefanidze
Stefanidze6mo ago
And about the continious generation model, store all the data on what to generate next in every chunk's corner, and then check for it when continuing generation But you will only be able to generate chunks continuously, so add some king of stopping mechanism so the chunks whouldn't get generated two times
Want results from more Discord servers?
Add your server