Procedural Noise that Covers the Entire Solar System

With the foundation essentially done, I’m starting to nail down the specifics of the game, like “Where will all the enemies be?” and “How will the player progress through each level?” The primary tool for level design (to the extent that Ladon even has levels) is procedural noise.

I learned about “Perlin noise” and “Simplex noise,” which are both used commonly in games. No surprise, I decided to write my own noise function instead of using either of those. For one, I’m not entirely sure if there are copyrights or licensing issues with those algorithms. Honestly, it took me less time to write my own function than it would have to fully research Perlin and/or Simplex and port them into BabylonJS.

I ended up with an extremely simple algorithm. I just pick a random number for each cell of my spatial grid, then linearly interpolate those values between cells. By layering different “octaves” of this random noise, I can get some really smooth, cloud-like noise. The image at the top of this post shows how the function looks with three layers. More layers makes it smoother, fewer layers makes it more turbulent.

I’ll use this noise function to place just about everything – enemies, asteroids, and space junk. The planets and bosses will be manually placed.

One consequence of building the noise function is that I had to finally settle on what the actual size of the game’s map would be. The main constraint was my random number generator. It uses a seed value that is 48 bits, which means that it can only generate 248 (280 trillion) total unique values. So that is the upper limit on how many sectors I can have if I want them all to be unique. The other constraint is the actual size of the solar system. In round numbers, it’s about five to six trillion meters from the Sun to Pluto. Yep, you can fly across the entire solar system if you’re willing to press the up-arrow key for five years (that’s literally how long it would take).

Given those dimensions of space and my RNG’s limit, all of the other numbers fell out of the equations naturally. A single sector is a 3km by 3km square. A region is 150000 x 150000 sectors. Finally, there are a total of 12000 regions. Most of them are nameless, e.g. “Region: 123,” but each planet (or planet-like thing – Ceres, Pluto, Orcus, etc) has it’s own named region like “Region: Earth.”

Check out version on the releases page and start holding down that arrow key so you can get to Pluto by 2026.

Leave a Reply

Your email address will not be published.