# Generate random point inside Perlin noise?

I’m working on terrain generation for a game of mine and has run into a slight problem. The terrain itself within the game procedurally generates as your character moves around. This means that all the world generation needs to somehow be based off of the position a certain tile—or region (chunk)—has in the world.

The world generation is rock solid so far and looks quite gorgeous! But I require one more component to make it complete—I need to somehow retrieve a random point within a piece of Perlin noise.

Let’s assume we had something like this:

int scale = 100;
float noise = perlinNoise.noise3(x / scale, y / scale, z / scale)

if(noise > .2f)
setPixel(x, y, 0xffffff);


We’re drawing the result to the screen in form of pixels to try and see what happens. This way, we achieve regularly spaced out areas of noise. Now, what I would like to do is randomly generate one point located somewhere within a chunk of noise following the above “schematic”.

The above might look something along the lines of this:

xxxxxxxxxxxxx
xxxxxxxxxxxxx
xxxxxoooxxxxx
xxxxoooooxxxx
xxxxxoopooxxx
xxxooooooxxxx
xxxxxoooxxxxx
xxxxxxxxxxxxx


Where the x’s are what is not affected by the perlin noise in the above code example and o’s are affected—the o’s are plotted out on the screen by it—they’re the white pixels in the above example.

The little p as opposed to from the o’s and x’s, is the random point I’d like to have randomized inside every chunk of randomized Perlin noise, without having to pre-generate the world.

Is there a way in which this can be achieved? I’ve wrapped my mind inside out thinking of potential solutions—I’ve searched the web, but as though in vain. There appears to be nothing written on the subject.

• The p is only allowed to go in a position where an o would be? Feb 1 '17 at 16:18
• @Byte56 Yes—that’s correct! In fact, there needs be one—and exactly one—*p* as for every chunk of o’s. Feb 1 '17 at 16:20

Keep a list of the positions for os for each chunk. When the chunk done with the Perlin noise generation, select an o randomly from the list to be replaced by a p.
• I suppose it's not clear to me how you're generating this noise then. Do you not have chunks for data you're generating, each are supposed to contain one p? Are you generating chunks at some other time, then adding Perlin noise to them after? How do you not know which chunk Perlin noise is being introduced into? You don't need to know anything about surrounding chunks, because you're only concerned with a single chunk at a time, the noise you're adding to it and the single p you're adding. Feb 1 '17 at 18:19