Playing God - The troubles of creating a real-size universe!

Published April 06, 2017
Advertisement

A comment to my previous blog entry was pretty right on the nose: Stream of consciousness. I do that a lot, thinking as I write and ending up writing my thoughts down more or less as they come to me. I'll try something else this time around, but do go to that entry and see if my thoughts don't happen to align a little with yours. Also, I'm still running a test there, so... can you stand not knowing what kind of test it is? Just asking...

But more constructively: I'm trying to use science to recreate entire universes inside of computers. I work a lot with math, even outside of programming (I teach mathematics), and over the last half to whole decade, I've become rather angry about a certain topic. That topic is procedural generation. Now, I'm not angry that people use it. In fact, it bothers me more when commenters and such start ranting against PG as if "oh, it can't create anything truly interesting *insert arrogant cackle*". Let me make this clear: PG can create anything a person can create. Wanna know why? Because a person created the PG. If you wanted, you can create something cool and then reverse engineer it to make it PG. Design a cool storyline with cool characters inside a really cleverly designed space station or dungeon or city or whatever? Take each piece of it and create alternative pieces that could function in their place just as well. Pick a differently designed gun, a different height of scenary to be traversed, etc., and let the game pick which variation it uses every time. Voila, procedurally generated game, equal to what you could make n your own, because you made it. If PG creates something crappy, it's not because it's PG, it's because the person using it is not good at using PG. A painter has no right to blame the brush, a carpenter no right to blame the hammer.

What I suspect people actually mean is that PG does not create anything truly new. It just takes bits and pieces that humans made and shuffle them together in new ways. And for games like No Man's Sky, Spelunky, and others, that's true. But that's because their PG was designed that way. It's a testimony to humanity's desperate craving for control over its creations, and their resulting stiffling of creativity. We don't want games to create something really new and weird, we want them to create the things we imagined, but to do the work of making it for us. PG is not a creative tool, it's a shortcut. Hollywood would be proud of us wanting to cash in on mixing the same elements again and again and presenting them as something new.

I, on the other hand, am a card-carrying lunatic. I want madness, chaos, and unexpected results. But the First Rule of Procedural Generation is "Never go full random". Truly random results are nothing but meaningless chaos. It's the game equivalent of TV screen static (something that so many young people have never really seen, I suddenly realize. If that's you, google it, and behold the world of the past). So I must decide on what chaos to kill and what chaos to nurture. I make those decisions with my trusty sidekick, SCIENCE! (biatch)

starweb___holy_crap___by_embassyoftime-db1hf0w.png.jpg

That there is an image of my universe during a test. I start with random dots of light, then place invisible points that attract them based on proximity. It's an older version. A slightly newer version is this, a universe screenshot from 9 random angles:

newniverse__big__by_embassyoftime-db3rdr8.png.jpg

Each dot is a 'hypercluster', millions of galaxies seen from such a distance that they resemble just one dot. More up close and personal, the early test galaxies (colorcoded for testing) look like this:

galaxy_shower_by_embassyoftime-db3y5jx.png.jpg

These pictures are from different versions of the program, hence the sudden appearance of a HUD. Other versions have the actual stars and planets, but that is where a lot of my problems currently arise.

seaside_sunrise_by_embassyoftime-db39af2.png.jpg

smooth_sun_by_embassyoftime-db3a964.png.jpg

See, the big problem is not how to create the PG mechanisms to build an entire universe. I did this stuff in little over a month, on the side. No, the problem is how little things grow out of proportion. How a slight rounding of a tiny, tiny number can escalate and throw everything out of whack. Right now, I am rewriting everything to deal, again, with a way that double-precision floating number decimals (a.k.a. 'doubles') are handled in C++, my programming language of choice. The entire core of the matter is that detail is added along the way, based on some complex math (although the math I test it with is a much simpler, boiled down version of that, or madness would ensue). Here is a less realistic screenshot to exemplify that:

Munching%20Nachoes.png

One triangle polygon gets created, and as you approach it, it tesselates, breaking into smaller and smaller parts, for added detail (no detail added here, just the basic tesselation). What happens when something gets rounded just a little bit wrong? Things jump around, that's what! Suddenly, the new, smaller polygons do not line up. And then the next rounding problem makes them act even worse, and so on, until everything goes everywhere. This is my battle. This is the saddening fact of creating a huge universe to fit inside a simple laptop: Your entire work hangs on a few numbers being rounded off. I never had the "three days of work to find a 1 should be a 0", but I did almost have "two days of work to find a 2 should be a 4", so I feel like it counts.

But when it finally succeeds, I intend to reap the whirlwind. Not only can this create a universe of infinite (truly infinite, not this "very big number" hogwash) content, but it can make things in every size. And I mean every size, from subatomic machinery to monsters eating up galaxies (or something less insane, like the kaiju-like creatures of Shadow of the Colossus). The code doesn't care, it just puts in dots and polygons.

And with that level of flexibility, SCIENCE! (biatch) can make its mark on it. PG is not just "take these 18 modular pieces and slap them together randomly, over and over again". Algorithms exist for basic artificial life, for geological processes, for atmospheric phenomena, for stellar debris, for the spread of cultures and technologies, and for more. We are still living in the "I must control my assetts" era, but only because people use that mindset when handling PG. If you give in, chaos may give you more than that. Only you are no longer fully in charge.

All of that hinges on the rounding of small numbers. Ever wonder if even God knows the last digit of Pi??

And today's challenge to you: Write something in the comments that you do not believe procedural generation could ever create, and I will try(!!) to argue you wrong. No exact results ("PG could never recreate Legend of Mario: Vorpal Kombat level 31!"), but things that you might see, or want to see, in a game. Don't worry, I'll be gentle with you!

Previous Entry What are you?!?
4 likes 9 comments

Comments

Awoken

Please be gentle, please be gentle... hahaha.

I liked your little blog. I think the most likely problem you'll encounter is generating content that is meaningful to the end user and most importantly, assuming it's a game, fun. One idea I had reading your post is I wonder whether or not you could write a complementary AI which could 'refine' the variables so to say, so as to speed up the process of taking the universe-builds out of the realm of meaningless chaos into one that is familiar.

I likes I likes, I want your universe to generate a bottle of red wine!

April 06, 2017 10:26 PM
khawk

I'd be really interested in learning more about the algorithm/design/approach, given the challenges of rounding errors, or at least what could be said about it. It's an interesting topic for large scale simulation.

April 06, 2017 11:12 PM
Embassy of Time

Please be gentle, please be gentle... hahaha.

I liked your little blog. I think the most likely problem you'll encounter is generating content that is meaningful to the end user and most importantly, assuming it's a game, fun. One idea I had reading your post is I wonder whether or not you could write a complementary AI which could 'refine' the variables so to say, so as to speed up the process of taking the universe-builds out of the realm of meaningless chaos into one that is familiar.

I likes I likes, I want your universe to generate a bottle of red wine!

I'm always gentle :) (not really, but...)

Meaningful content IS a big factor in PG, and many fail on it (like No Man's Sky). IMHO, this is because they try to control the outcome, restricting it, and because they think of the PG as "the game". This is probably why simple PG games like Spelunky have more success, because the PG is kept very simple and not that influential. Spelunky could work just as fine with handcrafted levels, for example.

You don't need AI to refine the universe, at least not in the classical sense. You just need some heavy-duty math. The astrophysical elements (stars, planets, planetary chemistry, etc.) can be done with comparatively simple math, as they work more or less liniarly; things form, and they are just there. Like sending car off in different directions. The trouble comes when they interact (like the cars starting to force each other off the road). But that's basically 'just' a different kind of physics engine. Once life starts appearing, I have the basic math for a lot of stuff up until higher brain functions. At that point, it gets fuzzy, although overall society evolution is fairly well mapped out. It's the more individual stuff that's a challenge.

I'm interested in any more thoughts or material you have on the subject, in hopes that I can learn some good stuff. Marching cubes and space colonyization algorithms (neither are what their name suggests, by the way) got me very far, and once the tesselation works to a tee, I think I will be ready for the next great step. More knowledge and ideas can only help!

April 07, 2017 10:48 AM
Embassy of Time

I'd be really interested in learning more about the algorithm/design/approach, given the challenges of rounding errors, or at least what could be said about it. It's an interesting topic for large scale simulation.

So am I :D In all honesty, it's the one thing that really took me by surprise. I have learned more about floating point decimals in C++ these last two weeks than all the time before it put together! The go-to solution for me is to make everything a matter of multiple scales; when something is very far, it is simply put at a different scale, and rendered as such. Movement then 'just' needs to be translated between the scales. But I keep getting signs of inaccuracies, no matter what, and I think the movement-in-scales-translation is the key issue. At the moment, I can render an infinite universe, but once things need translating between scales, those little inaccuracies pile up, quickly!

If everything works right, I hope to, at some point, make the code open source. I am balancing that against my options for financing it, of course, but I think the right colab ideas on it could push modern games into new territory. Then again, I'm arrogant like that :)

April 07, 2017 10:52 AM
cozzie

Nice blog, really enjoyed reading the whole thing.

The challenge:

- I think it would be 'impossible' to PG quests of an RPG which interact/ line up with the main story of a game. With 'impossible', I mean that the efforts would not weigh up to the benefits (because in theory creating lots of small PG algorithms would still be PG, say one for every quest :))

April 07, 2017 11:21 AM
Embassy of Time

Nice blog, really enjoyed reading the whole thing.

The challenge:

- I think it would be 'impossible' to PG quests of an RPG which interact/ line up with the main story of a game. With 'impossible', I mean that the efforts would not weigh up to the benefits (because in theory creating lots of small PG algorithms would still be PG, say one for every quest :))

Thank you! I hope to be prolific and quality enough to make people actually read, and welcoming enough to make them engage with my stuff :)

As for your challenge... First go here: http://www.seventhsanctum.com/

None of that is exactly what you describe, but the extent of what some guy does for a hobby is impressive. I worked with artificial author programming a while ago, for kicks (yes, I am that level of weird, which I think means I belong here, very much), and once you view stories from a certain perspective, you can start to actually make them "tell themselves". But we probably agree that the big deal is not "make quests", but "tie them to the main story". On one level, I think you are right that the effort would outweigh the benefits. Creating formulaic questlines around a predefined plot or narrative would become tedious fetch stuff, like the poorly thought out sidequests that litter many modern games. The challenge, however, is not the PG quests. The challenge is in understanding your main story from a PG perspective. Most people take "the story is this" at face value, but by viewing the story as the result of underlying currents, you get a totally different perspective on it.

Think of Star Wars (any of the movies or animated series will do). If you think of them as stories, you focus on character motivations and how to bind interesting plot points together. You think emotional investment, setup, payoff, Checkov's Gun, and such. Stories, in a word. But now ignore the stories you know, and think of why they even exist. The (SW) galaxy has a history that creates a tension between factions, and the stories are results of that tension. Luke's character arc is the primary story, true, but as Rogue One shows, many lesser arcs are influential, and powerful, story-wise. If you imagine your main story as not the actual story told, but the many complex conditions that lead to it, PG quests (or even grander plots) become a different creature altogether. You may not be diving into the classic SW lore or the main fight/story, but you'll be running blockades and meeting hostile races and hunting traitors on Curescont (sp?), which is really what is going on in that universe.

Withut giving too much away, the game I'm working on has a very established story. It's about time travel, but across space, as well. Because scale can have at me, yo (I am very, very white, and it reflects in my horrible use of modern language). I write and will soon (hopefully) be overhauling the entire storyline into the first book (the previous three had to be trashed, because someone refused to let me use some rights :( ). Now, I could try to spin quests from the main storyline, but as stated, that would be a bad idea, probably. Instead, I am, from the get-go, designing the story universe with a certain structure of tension, and stories will erupt from there. The story does not tell the universe, the universe tells the story, so to speak. But it IS a different way to think about stories, so for classic storytelling, I still think you're absolutely right.

I should make this a future entry, shoudn't I?

April 07, 2017 06:42 PM
Acosix
Quote

 

All of that hinges on the rounding of small numbers. Ever wonder if even God knows the last digit of Pi??

 

Well the problem increases, when you start to realize...there is...no last digit of PI.

Quote

And today's challenge to you: Write something in the comments that you do not believe procedural generation could ever create, and I will try(!!) to argue you wrong. No exact results ("PG could never recreate Legend of Mario: Vorpal Kombat level 31!"), but things that you might see, or want to see, in a game. Don't worry, I'll be gentle with you!

A universe. A galaxy. A solar system. Proper brain functioning humanoid AI.

Take a look at it this way:

Quote

Playing God - The troubles of creating a real-size universe!

The title of this blog post says everything.

How could God create universe? Stick to me, Roman-Catholics, please.

There are SO MANY galaxies in the universe. And what are we, humans?
Just a speck of dust within galaxy called Milky Way.

So if you say in a complex system you change one number wrong, it collapses.

And so would universe, if there was something out of order.

And let's take this analogy back to the PI number. Calculators can calculate
100 divided by 3, which is 33.333 and infinite digits "3".

There is no last digit of the PI number which means, you still have to put this
insanely huge number into the universe.

October 13, 2019 07:25 PM
Jozin

Procedural generation cannot be created by procedural generation,  because initial procedural generation must be created by human, and until you programmer wont have something, the something is just nothing, and nothing cannot generate something by the definition. So because of this all the thing you calling "procedural generation" its just some kind of compression of initial data, just like those shadertoy elephants made with distant functions or something. I mean for each example of so-called procedurally created assets you need manually find some unique alghoritms, so you cannot create all the universe by just simple alghorithm until it will be something like ubershader,  wich is nothing more than concatenation of all the alghorithms, your procedural generation is predictable and cannot create anything but create fixed things (even you consider 4d fractals), its just another 10000000 gun combinations (but composed from pre-defined parts). So I think for now its not possible to create all the world using procedural generation, because world is infinite but possible human's coding time and knowlege in each moment of time is finite. Amen))

October 14, 2019 05:44 AM
Embassy of Time

Re: Creating universes full of galaxies with PG, I doubt that would really be that hard, theoretically speaking (it would take time and study, for sure). This is mainly science, all working on mathematical laws. It's a puzzle more than a mystery, putting all the existing pieces together. Some tricky math would be needed to fill some gaps, creating a faux random structure. But from supernovae to grains of sand (or something more... esoteric?) on a shore, I started down this road believing it to be possible, and I admit I still do!

Re: PG made with PG... Now that's a tricky one. Still, far from impossible. It's essentially the root of simple AI. I only needed 30 lines of code to make one of those things that scan a writer's writing and created a story that was like it, except when read closely was just a rambling mess of words, all style and no structure. On a similar basis, anything that can be expressed through a computer can be randomized, so I doubt it could not be procedurally generated.

Damn. Now I am getting the urge to do AIish PG of stuff. Down boy, down!

October 15, 2019 09:13 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement