#Waves x noise tutorial how to
I've written an article about how to use random numbers for damage in role-playing games where I give a bunch of tricks like this. As the game designer you get to choose the distribution of the random numbers you want. There are lots of tricks for taking uniform random numbers and turning them into non-uniform random numbers that have the properties you want. In Python it's random.randint(0,19) but I'll write random(0,19) in these notes.
Most languages will include some function to generate random numbers uniformly.
That means every location from 0 to 19 is equally likely to be chosen. The simplest thing to do is to use a uniform random selection from 0 to 19. We can use a random number to choose the location of that block. It can be anywhere from position 0 (leftmost) to position 19 (rightmost). Note how much these maps have in common: they're all made of blocks, the blocks are in a line, the line is 20 blocks long, there are two types of blocks, there is exactly one gold treasure chest.īut there is one thing that varies: where the block is. Let's write out some maps that we might like to see ("x" marks the treasure): map 1.
Let's make an extremely simple map generator: it will generate a line of 20 blocks, and one of the blocks will contain a gold treasure chest. As a designer, you need to decide which aspects are the same and which aspects will vary, and how they will vary.įor the parts that vary, you'll typically use a random number generator. But they also have some differences: where the biomes are placed, the location and exact shapes of caves, the placement of gold, and so on. For example, all the maps in Minecraft have a lot of similarities: the set of biomes, the size of the grid, the average sizes of biomes, the heights, the average sizes of caves, the percentage of each type of rock, and so on. What we're trying to do with procedural map generation is to generate a set of outputs that have some things in common and some things different each time. I also have some 2D noise experiments, including 3D visualization of a 2D heightmap.
#Waves x noise tutorial code
I don’t think any of this is new but some of it is new to me, so I wanted to write it down and share. So here are some notes on how signal processing concepts relate to map generation. As I was studying audio signal processing, my brain started making connections back to procedural map generation.