Looking in the code, the library provides
noise.randomize() which states:
Randomize the permutation table used by the noise functions. This
makes them generate a different noise pattern for the same inputs.
Thus, randomizing the function through the API provided is the most direct way to solve the problem.
Here's an alternative solution based on the the discussion in chat, which I posted before spotting the API function:
If you cannot directly set the seed for your noise (sometimes the case with library code), then you can get around this limitation by using a random scaling &/or translating (shifting) factor.
While I don't recommend using scaling for randomizing, many noise functions give a value of zero for integer coords, so we'll need to adjust for that eventually anyway. Scaling essentially means multiplying by some factor. So for example if your factor is 0.1 then the integer coords 0,1,2,3,... are transformed into the noise coords 0.0, 0.1, 0.2, 0.3, ...
Translating on the other hand can be done by adding some factor. Using 0.1 again as an example the integer coords 0,1,2,3,... becomes the noise coords 0.1, 1.1, 2.1, 3.1, ...
Next, here's how you can use them to randomize your map generation. A noise library I used was deterministic, meaning the noise values for a given coord are never randomized between runs. But I needed the values to change based on a game seed, so I translated my sampling by some random factor & that worked well enough for me. So as an example, when my map generation starts:
- I use a random number generator (seeded to the system time) to get a translation factor for both X & Y, let's call them
tY. Since the system time changes between runs, tX & tY should be different across each run
- Next, I use a scaling factor so that I sample at more than just the integer coords. Let's call that factor
- Putting it all together, if I needed to get a noise value for some x,y location, I would have something like this:
value = noise(x*s+tX, y*s+tY)
Depending on the size & scale of your map as well as the period of the noise generating function, translating & scaling may still leave you with unwanted repetition. The typical solution to is to combine multiple layers of noise with differing frequencies and amplitudes.
Frequency is controlled by scaling the X,Y inputs. Multiplying by a factor between 0-1 will increase the frequency, multiplying by greater than 1 will decrease it.
Amplitude is controlled by scaling the output from the noise function. Multiplying by a factor between 0-1 will decrease the Amplitude, multiplying by greater than 1 will increase it.
Together, the changes to frequency and amplitude are often referred to as octaves. Adjusting the octaves is a bit of trail & error art - the common rule of thumb is as you double one, you halve the other (or vice versa).
Even though the underlying noise function remains the same, the combinatorics of translation & scaling summed across multiple layers quickly creates enough variety to overcome repetitions.