Spawning objects on infinite 2D terrain using a seed.

I’ve been experimenting with infinite 2d (top down) terrain generation using perlin noise. Here’s what I have so far:

  • Each world has a unique seed generated by random.nextLong().
  • Terrain is generated, saved and loaded in 16x16 chunk files.
  • The perlin noise returns a number between 0-0255, I use this to generate a heightmap.
  • Using the heightmap values I set a tile id, if its below 64 its water, above 64 its grass, about 150 its snow; for example.

This is pretty basic so I want to start adding objects like trees, bushes, rocks and basic structures. I don’t want to spawn objects by random chance because if I use the same seed again the terrain will be the same but the objects will be in different places.

I’m struggling with placing objects in the world using a seed, so they will always be in the same place if I use the seed again. Any ideas?

Feature point generation. Using either a random or quasi-random number.

My suggestion would be to make another seed from that seed specified for object generation, meaning that the “object” seed would always be the same for the same terrain seed. You could also do this for water / beaches for example. First generate “hard” terrain (dirt, rocks, grass), then make a seed out of that seed and make a wet terrain (sand, water), and then make another seed from base seed to spawn trees and stuff.

That sounds like a good idea. My question is, how to use that seed to determine where objects (trees, bushes, structures, etc) are placed in the world?

trollwarrior1: that doesn’t even make sense.

What do you mean it doesn’t make sense? You make a terrain. Then you make trees. How doesn’t this make sense? You can’t really make everything in 1 go.

No offense intended but you obviously have no experience with procedural techniques. “make another seed from that seed” doesn’t have any meaning. If you force a meaning on it then it’s “a does nothing, goes nowhere” operation. I laid out the most basic way to procedurally place things in space on the feature point page.