• What We Do
  • Our Work
  • Information
  • Smart Solutions for Smarter Business

    Procedural Games and Reliable Randomness Back to blog

    eliteHave you ever played a procedural game? It’s a game where the environment, gear, and other things are created randomly every time you start a new session. This gives every player and every playthrough a somewhat unique experience. I say somewhat, because this randomness is selected from a known set of numbers. For example, a random number generator pulls out a number from zero to nine in order to decide what terrain happens in a certain area. Zero is a mountain, one is grassy plains, two is a swamp, etc. So it’s random, but only within a set of defined possibilities.

    One of my favorite things is randomness in programming, and my favorite kind of randomness is reliable randomness. What’s the point of randomness if it’s reliable, right? Isn’t reliable the opposite of random?

    A long time ago, a game called Elite came out for the BBC microcomputer. At the time, it was mindblowing because it contained eight galaxies, that’s right, GALAXIES, each with 256 unique planets. All of that fit into less space than a floppy disk. In fact, it could have been much much larger, over 280 trillion galaxies of that size, except for publisher intervention. They didn’t plan and design that many unique planets, but what they did is far more impressive.

    Let’s say you start out with a very large number. They worked in binary, but for this we can just think of it as a really long positive number. If I split that seed number into three equal sections, I now have variables that I can use in a formula. What they did, in a simplified way, was throw away the first section, move the second and third sections up one spot, and then used a formula on that first section to come up with an entirely new set of numbers, which goes in the final position. You now have a completely different number that is entirely based on the number that came before it. Every four “twists” using this formula results in a number completely different than any that came before it.

    So, from a common seed number, you can grow trillions and trillions of unique numbers. What the programmers of Elite did with those numbers was interpret the various bytes to do essentially what I described above: If the first byte represents the letter A, it’s a totalitarian government; B is a democracy, etc. What’s great about this is that every game will feature the same galaxies, the same planets, which can be debugged and fine-tuned without having to repeatedly generate random ones until the offending combination of any number of qualities happens.

    With this formula, a seed number, and a bunch of options to pick from, you can create more content than most games will ever have. Content that is unpredictable, but reproducible. How’s that for randomness?

    By
    Addama Sanders
    Lead Developer

    By
    Addama Sanders
    Lead Developer