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

In summary, The speaker is working on a 2D game in Python with an infinite map generated by a Perlin noise function. However, the speaker is struggling to figure out how to scale the distance between the troughs and valleys of the function to make the map features larger and less cramped. The speaker has tried to research and understand the process, but has not had success. Resources and hints for generating random maps with Perlin noise in Python are also provided.
  • #1
JohnLuck
21
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
  • #2

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

1. What is the purpose of scaling a noise function?

Scaling a noise function allows for the manipulation of the amplitude and frequency of the noise, resulting in more control over the final output. It can help create a more realistic and varied effect in applications such as computer graphics, signal processing, and data analysis.

2. How is a noise function scaled?

A noise function can be scaled by changing the amplitude and frequency of the noise signal. This can be achieved by multiplying the signal by a constant factor or applying a mathematical function to adjust the values of the noise function.

3. What is the difference between scaling a noise function and applying a filter to it?

Scaling a noise function involves adjusting the amplitude and frequency of the signal, while applying a filter to a noise function involves modifying the shape or distribution of the noise. Scaling alters the overall characteristics of the noise, while filtering only affects certain aspects of the signal.

4. Are there different types of noise functions that can be scaled?

Yes, there are various types of noise functions that can be scaled, such as perlin noise, simplex noise, and fractal noise. Each type of noise has its own unique characteristics and can be scaled in different ways to achieve desired results.

5. Can scaling a noise function result in a loss of quality?

Yes, scaling a noise function can result in a loss of quality if not done properly. It is important to carefully adjust the amplitude and frequency of the noise to avoid distorting or oversimplifying the signal, which can lead to a loss of detail and realism in the output.

Similar threads

Replies
13
Views
3K
Replies
3
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
11
Views
2K
Replies
6
Views
4K
  • Programming and Computer Science
Replies
6
Views
5K
  • Programming and Computer Science
Replies
3
Views
1K
Replies
2
Views
2K
  • Mechanical Engineering
Replies
1
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
2K
Back
Top