Procedural generation strikes a balance between randomness and order.
The amount of discoverable planets in the game No Man’s Sky is a ridiculous 20-digit number. Strewn across a computer model of the cosmos, these planets vary in size, atmosphere and climate. They are often populated by dinosaurs, which evolve and change shape from one planet to the next. Players could spend the rest of their game-playing careers exploring a single one of these destinations and not discover every nook.
Hello Games, No Man’s Sky’s British development house, is more or less attempting to recreate the dream of every 10-year-old: a game world so vast and ponderous that it is virtually endless.
How could a small team with a mid-sized budget replicate a universe that may be as big as the real thing? Given the enormity of the task, populating 18 quintillion distinct worlds seems impossible, even if every game designer on Earth was recruited to help.
The answer involves a fascinating series of algorithms that work together to create most of the game space.
No Man’s Sky and its pulp science-fiction galaxies depend on what is known in the game industry as procedural generation: a procedure that uses randomness and equations to generate art and assets for a game.
A primitive version of the process was conceived when Ken Perlin, now a professor at NYU, was commissioned to create a graphic filter for Tron in 1983. It was a quick fix to add texture to virgin computer graphics, and it worked.
Thirty years later, a similar technique was used to randomly assemble the infinitely blocky worlds of Minecraft. No Man’s Sky implements a “blueprint system” in the same vein.
“Our engineers told me you essentially take random elements and funnel them into a box of ‘maths,’” the game’s art director Grant Duncan said at the Game Developers Conference 2015. The results include sunsets of different hues, a large variety of indigenous plants and various species of animals that are as diverse as breeds of dogs.
Duncan’s “box of maths” contains a very complex set of rules that clump together chunks of information in random ways. But, importantly, it’s not completely random. It turns out that we still like to see some order in our procedural generation.
Daniel Cook, who has tried his hand at procedural generation in games like Triple Town and Road Not Taken, explained that the technique is actually fairly simple, comparing it to paper dress-up dolls.
“There’s usually a blank body. And then you have a set of shirts, bottoms and hats that you can apply. By mixing and matching various clothing pieces, you end up with a unique look,” he said. “Much of what we call procedural generation is very similar. Instead of shirt and hats, we are mixing together game level rooms and enemies. But instead of a blank paper body, we are hanging those pieces together by a set of rules.”
When this is repeated over fourteen hundred lines, the approximate size of No Man’s Sky’s source code, the environments become both sophisticated and serendipitous.
“In the best systems, players are regularly delighted by unexpected and never-before-seen situations,” Cook said.
In No Man’s Sky, this is not only true for the players, but for the designers as well. In a recent New Yorker feature on the game, Duncan revealed how he constantly gets distracted from working because he is exploring parts of the world he has never seen.
To aid his cause in painting the galaxy, he has enlisted in-game drones to photograph far-flung planets, since there’s no way he can inspect each one by hand.
It is a foregone conclusion there are pockets of space and huge chasms of the universe no one will ever see. Yet they will be out there, touched only by math and the rules of design.
When the universe is first “seeded,” an equation churns out some random numbers. These define the overall shape of the universe. Then, the universe generates more random numbers, which become the stars. The stars determine the number of planets that orbit each one.
The procedural generation goes on and on in this manner, unfurling all the way down to blades of grass and numbers of leaves on trees, all of which are just waiting to be discovered.