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

Click For Summary
SUMMARY

The discussion focuses on scaling the Perlin noise function in a 2D game map generator using Python. The user struggles with adjusting the distance between the troughs and valleys of the noise function, resulting in cramped map features. The provided code snippet demonstrates a basic implementation of the noise function but lacks the necessary scaling adjustments. Resources such as a comprehensive overview of Perlin noise and Python-specific hints are shared to aid in understanding and implementation.

PREREQUISITES
  • Understanding of Perlin noise algorithms
  • Familiarity with Python programming
  • Basic knowledge of 2D game development concepts
  • Experience with mathematical functions and scaling techniques
NEXT STEPS
  • Research "Scaling Perlin noise in Python" for specific techniques
  • Explore "Noise function parameters in procedural generation" for deeper insights
  • Learn about "Octave noise" to enhance map feature variability
  • Investigate "Python libraries for procedural generation" such as noise or perlin-noise
USEFUL FOR

Game developers, particularly those working on procedural generation and map design in 2D environments, will benefit from this discussion.

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)
 
Physics news on Phys.org

Similar threads

Replies
13
Views
4K
Replies
6
Views
5K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
1
Views
1K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 2 ·
Replies
2
Views
454