Procedural Generation: Programming The Universe
Video Statistics and Information
Channel: javidx9
Views: 158,117
Rating: undefined out of 5
Keywords: one lone coder, onelonecoder, learning, programming, tutorial, c++, beginner, olcconsolegameengine, command prompt, ascii, game, game engine, pixelgameengine, olc::pixelgameengine, procedural generation, pgc, universe, elite, elite dangerous, star systems, content creation, asset generation, random numbers
Id: ZZY9YE7rZJw
Channel Id: undefined
Length: 41min 57sec (2517 seconds)
Published: Fri Jan 24 2020
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
I didn't want to watch the whole thing, but am curious; did he make it so it can be saved, or is it just a one shot generation?
I'm not sure I agree with how he defines "procedural generation" and "automated generation" he talks about around 3:40. He says that if your algorithm is not simply generating things, on the fly, without any persistence, then it's not "procedural" it's "automated." Semantic quibbling enough? Odd that he doesn't think "automated generation" games like Minecraft are sufficiently "procedural," as it does have seeds that produce consistent results.
Speaking of semantic quibbling, I also find it a little confusing how he speaks as though he simultaneously wants to be random but also consistent with his results. Technically, then, not actually random. Of course, true randomness is fairly impossible on a computer, we can just get something that is "random enough" by seeding it with something unpredictable (he talks more about this at around 11:20, and I learned a bit about the importance of "robust" random number generators). Instead, what he wants is for it to appear random to the players.
At about the 18-20 minute mark, we get into some nice theory about how to use the robust pseudorandom numbers he's generating to make things look good. The rest of the video is pretty much a demonstration of how he breaks down his random generation into tables that do that. (About the 32-minute point he discusses how to translate a mouse vector, which is indeed another hurdle encountered with this strictly "procedural generation" method.) In my experience, once you have a suitably robust random number tied to coordinate shifts, you can pretty much do with it whatever you want, this part is easy.
However, for the purposes of a game, this is sort of the wrong way to go about it. (But a common approach - I would say that the vast majority of games that utilize procedural generation will do this to a middling-to-great extent.) Yes, it's easy enough to take random numbers and funnel them through some tables that you populate roughly on your understanding of how often various elements should be visible, and the result looks good to the human eye. However, my objection to utilizing this method is that generating things to look good is not the same as generating things to play good. It is a simple slip-up in core game design methodology that utilizes procedural generation incorrectly by forgetting the reason why you are using it: to create something the player plays.
If you do your procedural generation with the wrong priority first, you're stuck with it, it will be subtly undermining your game. Elite's universe generation (which this tutorial is based on) is actually a bit of a textbook example of this, as the universe structure does more to inhibit gameplay than enable it: it's big, and provides plenty to explore but, aside from being something to find, there's little rhyme or reason to its role in the gameplay. Thus, I somewhat interpret this video as an extremely well-done tutorial explaining how to emulate a method that misuses procedural generation, though the bit about the importance of "robust" random number generators was good.
His stuff is extremely good
It's a very good video. I have used it to make something like this in Godot . :)
He showed the Wikipedia page for a Lehmer generator, created a function called
lehmer32
, but what he implemented isn't Lehmer at all. It's an improperly-coded 64-bit splitmix generator. (Just as he speculated: His changes do compromise the integrity of the algorithm.) Wondering where he got this from, I did a search for his constants, but it only turns up his code. So did he copy this from some old, mistaken notes?Fortunately for him, an actual Lehmer generator wouldn't have solved his problem, and the result would look more like his experiment with
rand()
. However, at the core of splitmix is an integer hash function, which is what he really needed, at least initially, not a PRNG.His other videos are also very interesting. He made a tutorial for building a NES emulator.
Thanks so much for your informative reply skeeto! Iโm learning so much.
Regarding my โbetween 0 and 1โ comment: I dint understand % as the modulo operator. I typed multiply in my code. I thought he was getting a random number by multiplying a maximum value by a fraction of one. I see now that he is using modulo. Very cool.
Thanks for the python code line. I couldnโt get it to work. I added โimport mathโ, so that is not the problem. Splitmix64 throws a nameError.