Noise in Video Games

Noise in Video Games

At some point everyone encounters all-too-irritating noise when using a television. Noise is a good visual representation of using a random number generator (a.k.a RNG) in programming. Complete random numbers is ideal in many situations but when making programs to generate random worlds having a complete RNG is not particularly practical. In this scenario “coherent noise” (i.e Perlin Noise or Simplex Noise) can be much more useful. Coherent noise can be considered “pseudorandom noise” meaning that it is not absolutely random. The reason coherent noise cannot be considered completely random is that rather than each number having absolutely no relation the the last when using coherent noise each number does have a correlation to the last. This results in a smoother, more usable noise function.

Coherent noise is very common in video games, especially among the survival genre. Games like Minecraft, Starbound, No Man’s Sky and many more use coherent noise for many things. Minecraft and Starbound use coherent noise for generating their worlds, much like the demo program above although with more complex algorithms. No Man’s Sky is special in the sense that it uses coherent noise for much more than just terrain generation, almost everything in No Man’s Sky is randomly generated including the animals, the plants, the rocks and more.

The screenshots from the demo above shows the clear benefits of using coherent noise in contrast to completely random noise in the sense of generating a fluid, more navigable world. On the programming side of things coherent noise also gives the person writing the code much more control over the generation. This control is given by many factors, such as the ability to adjust the amplitude. In this scenario amplitude would be the maximum height value allowed.  You can see the code down below for the terrain generation function used in this example.

You can play the example project down below along with the source code or view it at: You can move around with WASD to see what worlds made with coherent noise would look like.

This particular demo contains multiple classes. There are separate classes for the tiles, the decoration tiles, and the player, a simpler way to understand classes when you’re just starting to learn about them is thinking of them as different objects. The tile and decoration tile classes are relatively simple, they contain the x and y coordinates of the tiles and just display them where they should be. The player class is relatively more complex as it contains the position of the player, but also contains the code which detects collisions between the players and tiles. The source code can be found below.

Leave a Reply

Your email address will not be published. Required fields are marked *