How can I scale the noise function in a 2D game map generator?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 4K views
JohnLuck
Messages
21
Reaction score
0
First I want to mention that I am not super good at maths and that I wasn't even sure if this was the right sub forum to post in (please move this to another one if that's the case).

I am working on a 2D game in python where the player plays on an infinite map. Of course that means that the map is generated by a function such that only the "tiles" on the screen have to be calculated and in memory at any time. The function I have been using is a Perlin noise type function that I found somewhere a while back, but I am unable to figure out how to scale the distance between the troughs and valleys of the function, so the features of the map are too small and look kind of cramped. I have really tried to figure out how to "stretch" the "distance" between these troughs and valleys, but I haven't had any luck so far. This is the code from my program:
(looks a bit messy)

Code:
def noise(x, y):
    n=x*331+y*337
    n=(n<<13)^n
    nn=(n*(n*n*41333 +53307781)+1376312589)&0x7blackf
    return int(((1.0-(nn/1073741824.0))+1)/2.0)
 
on Phys.org