Procedural Generation: Programming The Universe

  Рет қаралды 207,288

javidx9

javidx9

Күн бұрын

Пікірлер: 560
@bjarkeistruppedersen8213
@bjarkeistruppedersen8213 4 жыл бұрын
Sorry for asking, but is the last videos about the NES emulator still on the drawing board? :)
@javidx9
@javidx9 4 жыл бұрын
Yes, two more, but they will be towards end of February, mappers, and then one on finishing the audio. I felt the channel needed a break from NES as not everyone was interested, especially as you start getting to parts 7 & 8, which demands huge commitment from only the most die-hard of viewers, but also I needed a break, as I'd done nothing but NES emulation for almost 9 months XD I get that for those following along, a small wait is frustrating, but from my perspective, the series will be around forever, so all those in the future watching will be able to watch the whole thing. During my time off, Ive been working on a couple of small non-NES related projects so I'm gonna show those, then complete the series.
@bjarkeistruppedersen8213
@bjarkeistruppedersen8213 4 жыл бұрын
@@javidx9 great, I don't mind the wait - I've been thinking about getting back into C++ again, and think following along from the beginning will be a good brush-up 😀
@anunnakiosris8179
@anunnakiosris8179 4 жыл бұрын
@@javidx9 please make copy Agar.io
@Dante3085
@Dante3085 4 жыл бұрын
So, instead of storing something in memory, we store it in the algorithm. That's really smart.
@javidx9
@javidx9 4 жыл бұрын
That's exactly it Dante, wonderfully phrased!
@Dante3085
@Dante3085 4 жыл бұрын
@@javidx9 Thanks
@pixelflow
@pixelflow 4 жыл бұрын
It was also necessity for early games, wasn't any storage to be had! Starflight is another great example of using procedural generation to create a vast universe.
@brettpaterson7478
@brettpaterson7478 4 жыл бұрын
Until you want to modify that thing..
@Nick-kb2jc
@Nick-kb2jc 4 жыл бұрын
Mind Blown 🤯
@RotBaron
@RotBaron 4 жыл бұрын
Carl Sagan: "If you wish to make an apple pie from scratch, you must first invent the universe." javidx9: "say no more fam"
@achtsekundenfurz7876
@achtsekundenfurz7876 4 жыл бұрын
31:34 And there it is again, the "cluster of planets" (stars actually). He scrolled left and right, down and up, and found his way back!
@THExRISER
@THExRISER 4 жыл бұрын
As someone who *REALLY* loves procedural generation and wants to get into it,you have no idea how valuable this is,thank you so much!
@PieRack
@PieRack 4 жыл бұрын
J: Let's procedurally generate the universe" Me: * spits tea everywhere *
@CoughSyrup
@CoughSyrup 2 жыл бұрын
I think the word you're looking for is: Deterministic. The PRNG will generate a sequence of pseudo-random numbers, and that sequence will be deterministic. I like your distinction between procedural generated and automatically generated. I don't know if this is the common understanding of the term, but it seems useful and so will adopt it.
@Gleem
@Gleem 4 жыл бұрын
I really like your videos, not that it means much, but I think you are clear and articulate and actually have a personality so salute sir keep going, I love them..
@javidx9
@javidx9 4 жыл бұрын
Hey thanks Gleem!
@taureanwooley
@taureanwooley 4 жыл бұрын
Best idea about creating the universe is creating the idea of the universe. Meaning knowing how it looks is always the most important part of the creation otherwise it wouldn't be experience in our view. There's a huge amount of thought that goes into the creation of the placement of the objects, but it's quite importantly the most complicated thing to recreate simply because of overlap, but with the right theories, you can create what is called a fractal norm which is perceivably the closest thing to proper representation. With the correct correlating variables, the fractal norm can be diluted into a more visible form which will create a resulting overlap of equations and understandings using numerical constant values for a particular time in space. That being said … thanks for making the thing that I asked you to do.
@HisDivineShadow
@HisDivineShadow Жыл бұрын
As others have noted, Minecraft is based upon deterministic seed world generation. That's why Minecraft speedrunners search for seeds with a particular world generation.
@Bigandrewm
@Bigandrewm 4 жыл бұрын
Concerning the distinction between procedural generation and automatic generation, I'm reminded of a classic PC game that did both: Starflight. Resources like fuel, minerals, and life forms were automatically generated, but the terrain itself was procedurally generated, and as far as I know, is one of the first games to do so. For the same reasons described here: the game had to fit on one floppy disk, and there was no other way to "store" the terrain data for over 600 planets in such limited space. The resource data was only stored for a much smaller area in the vicinity of the player's ship, and became "forgotten" and re-generated as the player explored.
@darektidwell1158
@darektidwell1158 4 жыл бұрын
Your lack of adherence and therefore respect for customary use of seed value 42 in the making of universes is appalling. Shame, sir. Shame.
@Sparkette
@Sparkette 4 жыл бұрын
But then you'd just get the Hitchhiker's Guide to the Galaxy universe, which lots of people have seen already. Wouldn't you rather see something new?
@al424242
@al424242 4 жыл бұрын
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.
@whattowatchrightnow
@whattowatchrightnow 3 жыл бұрын
42 is what you make of it.
@Whateverworksism
@Whateverworksism 4 жыл бұрын
YES! A new Javid video! I haven't watched it yet but I always get so excited. Guess what I'm going to use my weekend with? Visual Studio and Javid! :D
@javidx9
@javidx9 4 жыл бұрын
A whole weekend programming! Bliss!
@Spu7Nix
@Spu7Nix 4 жыл бұрын
Finally i can be the master of my own world
@ShadowGaro
@ShadowGaro 4 жыл бұрын
@Markus Zeller If you use the same seed you can create alternate timelines
@GregoryTheGr8ster
@GregoryTheGr8ster 4 жыл бұрын
Good morning, Javid! You read my mind in this video, for I have been musing about the very same programming challenge as of late (though for a terrestrial setting, not a stellar one). I can't watch your entire video right now, so I will come back to it in installments.
@Zorbaq69
@Zorbaq69 4 жыл бұрын
What a happy coincidence, I've been dabbling in my own procedural universe for little over a year now. Your excellent explanations would have saved me a lot of headaches early on as I was learning programming and experimenting with procedural generation. I love your videos, they keep me motivated and I find them very helpful even though my main focus is Unity w/ C#.
@javidx9
@javidx9 4 жыл бұрын
Thanks Zorbaq, I try to show things in a language agnostic way. You could take a technique like that shown and implement it in whichever platform you prefer, I just find C++ simple and convenient.
@VoidloniXaarii
@VoidloniXaarii Жыл бұрын
Have been for decades now fascinated by randomness... This vid has such great insights! Thanks so much. You're so awesome yet again
@biohackingonabudget3002
@biohackingonabudget3002 4 жыл бұрын
I watched this video while on a fair amount of LSD, and it changed my life
@peterklenner2563
@peterklenner2563 4 жыл бұрын
Such a serene narrative, quite hypnotic actually. No debugging necessary. We are moving quite casually from A to B to Z. Of course, rand is rubbish and the mersenne-twister is slow. That is why everybody chooses Lehmer random numbers ... Keep up the great work :)
@erictko85
@erictko85 4 жыл бұрын
I dont think it was a random number generator which put this video in my recommended feed. No, it was meant to be. I dont code but Ive been wanting to watch people code and talk about what they think while they do, so I really appreciate your video and like your style of guiding it along. New subscriber!!!
@okkewarner
@okkewarner 3 жыл бұрын
I'm completely honest, the first I came on to your channel, I was mostly pissed of, because I searched for things like algorithms and procedural generation. But I was completely new to programming (which I'm still) and needed those things in Java... :) And your videos "blocked" the KZbin search page, whilst they gave a lot of information about how to do in theories but still not showing how to implement it in Java... (Yeah I'm dumb to judge a channel about C++ by not showing stuff in Java). Complete misjudgment... Your videos are by far the best about algorithms and so you can find on KZbin. And really want to thank you for your effort!!!!
@techvigator
@techvigator 4 жыл бұрын
This is one of the best, if not the best, channel I've ever discovered. It is useful from start to finish... also to improve my English. Thank you to exist sir.
@PeterWTaylor
@PeterWTaylor 3 жыл бұрын
That was a facsinating discourse. I've played elite dangerous horizons many times and am amazed at the extent to which you can keep zooming in right down to individual stones and pebbles, and they are still there when you come back. I don't pretend to understand the mathematics but the principles are clear to me now. I bet George Boole would have been glued to the screen every second.
@Kenionatus
@Kenionatus 4 жыл бұрын
I recommend to have a look at perlin noise and its derivates. It is usually used to generate terrain and textures. The way I understand it, multiple, randomly generated, smooth curves are overlaid on top of each other to simulate mountains ranges (large scaling factors), single peaks and valleys (medium scaling factors) and the single rocks etc. (small scaling factors).
@rapids7841
@rapids7841 3 жыл бұрын
in the video you had mentioned that you hope in the future there will be hardware based random number generation, this already exists! Its called RDRAND, c++ even has intrinsic functions for processers that support it!
@theronster345
@theronster345 4 жыл бұрын
this is awesome. I've been looking around for something easier to understand and you nailed it. Thanks for the vid
@greob
@greob 4 жыл бұрын
I love this procedural generation topic! Always wondered how it's done, this is a great video. Thanks for sharing!
@notlaw1567
@notlaw1567 11 ай бұрын
Never seen a video so simply well detailed, instructive and interesting. Thanks for sharing your knowledge with the world❣
@sqaxomonophonen5998
@sqaxomonophonen5998 4 жыл бұрын
It may be more appropriate to use a hash function (like xxhash) instead of an RNG (random number generator). In this small example it doesn't matter, but you might run into problems if you try to make a full game with this RNG approach: - The universe size is constrained to 2¹⁶×2¹⁶ because the star position is used as RNG seed, and the seed is a 32-bit integer. A hash function maps _any_ number of input bytes to a random number, so a practically boundless 2⁶⁴×2⁶⁴ universe would pose no problem at all. - If you want to create a different world every time a new game is started, you must provide the RNG with additional input; simply generate a random "master seed" before the game starts, and use it as input. So for example, to determine if an (x,y)-coordinate contains a star system, you would use [masterSeed,x,y] as input rather than [x,y] alone. A hash function makes it trivial to add extra input, but the 32-bit RNG seed has no room left. - The star generator is sensitive to changes because the RNG is seeded once, and then used to generate a _sequence_ of random numbers. So if you were to change the order of rnd*() calls (or add/remove calls in the middle), you'd end up with a different universe. You could instead use the hash of [masterSeed,x,y,1] to determine the star radius, [masterSeed,x,y,2] to determine the number of planets, [masterSeed,x,y,3,planetIndex,1] to determine the number of moons for a given planet, and so on. This is more robust against changes, because the output depends only on the input, not the order of calls.
@kossboss
@kossboss Жыл бұрын
Interesting. Curious to see the result
@defeatSpace
@defeatSpace 5 ай бұрын
Thank you very much. I'm setting this up in Unreal and am really struggling to normalize the lattice with my coordinate offsets. Yep, I discovered the same thing (and why Minecraft is so weird with its directional biases lol) I lose total generation volume for every additional axis I add to nProcGen because earlier values must be made sure to be larger than other values after the bitwise or. UINT64_t u64_h; u64_h = UINT64_MAX / 2; seed1/2/3 = u64_h + (offset x y or z); was promising until realizing the uints are just overflowing after bitwise and still nullifying. Not to mention, I cannot for the life of me, get Unreal to play nice with uint128 for lehmer64. Anyways, again, thank you very much for sharing your knowledge! Edit several hours later: Yeah, his units increment by 50 and mine increment by 'double', so normalization isn't a problem for the 2D demo because (I think) the base movement unit is larger than sector size. So with double, normalization just takes the floor of the quotient 'PlayerPos/n' where n is 'static ... RenderBase/SectorBase'. And now, I'm having fun flying around exploring a procedural infinite lattice of debug spheres that gets weird super fast so I definitely have to implement XXH3 😆
@defeatSpace
@defeatSpace 5 ай бұрын
Sqax, you're the godfather of an imminent cultural phenomenon.
@defeatSpace
@defeatSpace 5 ай бұрын
or* godmother lol I'll reply with the title to reference near its release, and you definitely get a free copy (Steam-key (best for updates), raw-build, -console port,- whatever works best for you). In addition to the personal free copy/key, the game will also be free on Steam for the first day or so 😄
@sqaxomonophonen5998
@sqaxomonophonen5998 5 ай бұрын
@@defeatSpace Awesome if it turns out to be useful :D It doesn't have to be xxhash, just anything that takes an arbitrary-length sequence of data and turns it into something "sufficiently random". If performance isn't important, then something like md5/sha1 works great :-)
@vincentcleaver1925
@vincentcleaver1925 4 жыл бұрын
This time rewatching I was paying attention to your system layout and I like it a lot; an animation is kewl, but this is much more efficient
@Bathog44
@Bathog44 4 жыл бұрын
Fascinating! Converted the Lehmer routine to C# in a WPF project and did the Stars and Planets as icons. Works brilliantly, thanks javidx9.
@foibgames
@foibgames 4 жыл бұрын
I've started working on a project which is highly inspired by the first elite game and now you're uploading this... nice timing! xD
@realcygnus
@realcygnus 4 жыл бұрын
Superb content. The idea is quite clever imo, I had only vaguely known about some of the very basic concepts. It is much clearer to me now. Can't wait for more.
@javidx9
@javidx9 4 жыл бұрын
Cheers cygnus!
@NeilRoy
@NeilRoy 4 жыл бұрын
Great topic! I was thinking about just this sort of thing recently. I think the biggest problem for me was how do you know what you are selecting and I love your solution and how simple it is. That was also a great example of the default random generator. I honestly never really cared about the whole random number problem, but that demonstration really opened my eyes. ... Although Minecraft does store the world, it does add to it as you play, it generates a larger and larger world as you explore, but then saves it. It uses a fixed seed to create the same world, which I have tested from seeds I have seen online. I am not sure if you could get away from saving something in a game like Minecraft where the world is altered by the player so drastically. Perhaps you could just save what you alter, so it is procedurally generated, then the changes are loaded in? Could be a solution. You would still be saving something, but only what has been altered. Great topic anyhow, if you have a solution where nothing would need to be saved (except perhaps a user defined seed) I would like to see it. I suppose it depends on the game itself. Certainly SOMETHING has to be saved in a persistent universe where the player is changing, building etc.
@nomoturtle1788
@nomoturtle1788 4 жыл бұрын
Cheers Javid for another great video. Can't wait to give up real life so I can spend all day playing with code. One day. There's another channel that does a series called coding adventures that does game related programming exploration and mathematical modelling. Between the two of you I plan to build a library of skills and techniques and begin my own journey to make dumb programs and games. That's my dream, and it's enabled thanks to you Javid. Thank you.
@ianrhys
@ianrhys 3 жыл бұрын
One of the best tutorials for procedural generations or as i like to call it (seeded random number generator with rules) starters ...... much luv mate. Keep up the good work. Would love to hear more.
@cladepro
@cladepro 4 жыл бұрын
After learning the generation method, i'm really interested in the storing process of interactions with procedural entities, glad you'll make a video about it :)
@skepticmoderate5790
@skepticmoderate5790 4 жыл бұрын
Just store the changes in a hash table with the sector as the key. Then retrieve that entry when you need the data. Store the hash table along with the seed to disk to get a save file. Tada!
@ItsHyomoto
@ItsHyomoto 4 жыл бұрын
Another excellent video. Very concise, and lends a very practical description. I have an entire book on procedural generation that might make more sense now. Thank you!
@Mythricia1988
@Mythricia1988 4 жыл бұрын
I've always had sort of a vague idea of how this works, but seeing is really cleanly (and simply!) laid out has inspired me to open up a code editor for the first time since new-year! Also, not sure if I'm wrong or if this is just a nitpick, but I'm fairly sure Minecrafts world is procedurally generated, since the game does have the concept of seeds that will re-create an identical world every time it's input (even on another machine etc). It does also generate new chunks on demand. I think the reason it's stored on disk is because it's faster, due to the sheer amount of generation that is done per chunk, it's faster to read-back from disk after creating it once. So, the storing to disk part is not critical to the creation of the world, but rather convenience and speed, and as you alluded to at the end, to store changes to the world. But maybe that's what you meant? And, I'm really looking forward to seeing how persistent changes can be implemented! I'm imagining it comes down to basically storing the changes to disk, rather than storing universe chunks. That way, you only need to store the changes the user has actually inflicted on the world, which in comparison to the entire universe is obviously tiny... But interested to see the details of that.
@MrAlaxUA
@MrAlaxUA 4 жыл бұрын
As far as I know, Minecraft procedurally generates all the chunks except for the ones which were updated by a player. However, even in this situation, only the changes are stored while the chunk is regenerated on load. Loading from a disk will always be hundreds of times slower than generating even the biggest of terrains.
@Mythricia1988
@Mythricia1988 4 жыл бұрын
@@MrAlaxUA I'm not sure that's true, every chunk that MC generates is stored and compressed to disk in its entirety: minecraft.gamepedia.com/Chunk_format Including lots of extra data like precomputed light data etc. But this happens regardless of whether the player makes changes to the world or not; it's still loaded and saved to disk after initial generation. The CPU load from generating chunks is actually really significant, so loading from disk is preferable, because its not resource intensive (each chunk is only about 50MB or so). This frees the CPU to actually be busy drawing and simulating the loaded chunks rather than regenerating them on the fly every time, which when you think about it, would be a colossal waste of processing power - why re-generate every time you load a chunk, when you can just do the work once, and store it? The MC world is incredibly complex, so it makes sense to do it that way. If the world is trivial though, its faster to do it on the fly. Up to a point, at least.
@piotrt.3652
@piotrt.3652 4 жыл бұрын
@@Mythricia1988 Exactly, in some modern games we can even hear about generating terrain/chunks etc on GPU because generating them on CPU would not be fast enough for real time game (for example games with voxel terrain where you can make holes etc in terrain).
@ShadowGaro
@ShadowGaro 4 жыл бұрын
The chunks that are modified must be stored to disk otherwise the changes that the player made will be reverted. Procedural generation creates worlds but does not track the changes on them. You can be smart and just track the changes themselves though. For example block(0,0) is dirt, block(10,12) is air, etc.
@Saboteur709
@Saboteur709 4 жыл бұрын
I'm guessing that Minecraft stores to disk the chunks you visit; even if you haven't changed anything.
@minijimi
@minijimi 4 жыл бұрын
Can't believe that Elite was programmed an a speccy 48. Pretty amazing. Lots of respect to the game developers from back in the 80's.
@PhilBoswell
@PhilBoswell 4 жыл бұрын
Short, sharp, funny, and to the point…a bit like impaling really 🤣 I always look forward to your videos and I even manage to understand some of it still. Thank you!
@javidx9
@javidx9 4 жыл бұрын
lol, thanks as always Phil XD
@irene1307
@irene1307 4 жыл бұрын
New video - instant upvote.
@SpringySpring04
@SpringySpring04 4 жыл бұрын
They were right... He _would_ program the entire universe! We called it!
@RickeyBowers
@RickeyBowers 3 жыл бұрын
Minecraft is procedural in the data generated for a given seed, but once that level data is put in motion it needs to be saved. Fire, water, and NPC's can alter the generated data. If your universe had a Deathstar that destroyed planets you'd need to store that information somewhere as well. No Man Sky works this way as well. Modern processors do have a "real" random number generator, but it's "slow" and should probably only be used for seeding a quality PRNG. Thank you for the wonderful videos! [just finished the video - you mentioned the above at the end] :P
@rayboblio
@rayboblio 4 жыл бұрын
I loved this. It was like watching that show a few years back with a secret magician explaining how a bunch of magic tricks actually work. Thank you :)
@davidchapman3228
@davidchapman3228 4 жыл бұрын
I always enjoy your videos. I have spent my whole career in IT but from a business programming perspective. Always wanted to code in Graphics, i find it fascinating. This was very refreshing. I will be trying this soon... Thanks.
@javidx9
@javidx9 4 жыл бұрын
Thats cool to hear David. I'm specifically not that interested in graphics, but lots of people respond well to visual stuff, especially on videos XD
@davidchapman3228
@davidchapman3228 4 жыл бұрын
@@javidx9 thanks for the reply. I too have been a follower of Elite. I have one question, trying to get olcPixelGameEngine working in VS2019. I have the include statement in the code but it cannot seem to find the file. I have included it in the project linker general additional library directories. Any thoughts? Regards Dave.
@javidx9
@javidx9 4 жыл бұрын
@@davidchapman3228 The easiest way is to just have the .h file in your project folder, and include it as necessary. there is nothing to actually link. This may help: kzbin.info/www/bejne/m4WqhIeKrbdgidU
@davidchapman3228
@davidchapman3228 4 жыл бұрын
@@javidx9 magic, that did the trick. Thanks
@RokyBanana
@RokyBanana 4 жыл бұрын
This brought back fond memories of Elite:Frontier, which was the first one I played and loved, and how it had a whole frickin' universe to explore in glorious A500 colors while only occupying one single 3.5" disk. That blew my mind back then. Countless cargo shipments to and from Barnard's Star wasn't that fun, though, haha!
@esu7116
@esu7116 4 жыл бұрын
I just subscribed to your channel. Your voice is calm, your explanations are clear, your videos make me want to code even more Thank you 👍
@javidx9
@javidx9 4 жыл бұрын
lol thanks Esu!
@mattkey7226
@mattkey7226 4 жыл бұрын
Minecrafts generation is deterministic. The chunks don’t have to be stored, they just are so player interaction with the world is not lost.
@Gogglesofkrome
@Gogglesofkrome 4 жыл бұрын
ideally there should be a function to check if there had been player interaction with the world in order to avoid bloating up memory, since a portion of playing minecraft comes down to crossing massive oceans or roving across reaches of land that often provide no unique reason for players to interact with them
@davidmartensson273
@davidmartensson273 4 жыл бұрын
@@Gogglesofkrome But just being in a chunk in minecraft will change it since there are mobs moving and plants growing and as soon as a chunk is created that process is started and the state of it is changed from before. So yes some chunks might not be changed in a visual way, but still there often are changes. This was discussed in detail in a video regarding one anarchy server where hacked clients are used to find player bases by identifying how much each chunk had changed from the original creation, thereby allowing the searcher to see how long the player had been there. So, in theory you might save a bit of space but that was not the primary priority.
@Gogglesofkrome
@Gogglesofkrome 4 жыл бұрын
@@davidmartensson273 Most biomes don't have anything growing while you pass through them, and mobs aren't dedicated to memory so long as they haven't been fed or tagged, with the only exception of the enderman, which is the only mob that changes the environment without user interaction. If you're running through the landscape and not touching so much as a thing on your way through it, then it would be effectively identical to a fresh map gen, and as such if the developers were more storage optimization focused, this generated data wouldn't be saved. The reason it is saved is to spare the processors the repeated effort of regenerating the same areas over and over again.
@fpsoftdev
@fpsoftdev 4 жыл бұрын
@@Gogglesofkrome the problem is speed. Generation causes lag in Minecraft because procedural generation takes time. So if chunks weren’t saved to memory, every time you cross over a chunk you’d have to generate it again. A lot of this is due to the fact that Minecraft is not multithreaded. If chunk generation were on a separate thread you could do it this way.
@Gogglesofkrome
@Gogglesofkrome 4 жыл бұрын
@@fpsoftdev this issue of speed is generally what I was referring to when I was talking about the generation being used to spare the processors the repeated effort of regenerating the same areas over and over again. It's too bad minecraft came into existence within that time period that multithreading had only just become widely available; otherwise a lot of the issues of performance on a general level wouldn't exist.
@MarkSapsford
@MarkSapsford 4 жыл бұрын
I am hyped for this video (I will watch it later) and a elite player (1984, Frontier etc and elite dangerous) I am excited by procedural generation.
@javidx9
@javidx9 4 жыл бұрын
I love Elite too, always have!
@RogueShadowTCN
@RogueShadowTCN 4 жыл бұрын
My first thought for changing state in such a system, if change occurs, generate and store changes, check for changes at the coordinates selected as you select.
@PleegWat
@PleegWat 4 жыл бұрын
Cryptography actually requires both real random numbers (which are generated in hardware) and pseudorandom numbers. Using your star system as a parallel: It is important that if two people determine the information about a star system at the same coordinates, they get the same results. However it is also important that given the properties of a star system (but not its position in the grid) it very hard to deduce the original seed (or grid position) used.
@wojtekburzynski654
@wojtekburzynski654 4 жыл бұрын
41:20 that question came to my mind few minutes before you asked it and i gave it a thought. Probably i would use some map, where key would be taken from generation algorithm and value would be difference between generated state and current state. This solution breaks your definition of procedural generation, but quite simple.
@GiboonCloudSmoker
@GiboonCloudSmoker 4 жыл бұрын
I've learned so much in less than 42 minutes. Thank you!
@vincentcleaver1925
@vincentcleaver1925 4 жыл бұрын
To be clear, for a different universe I could have a seed # which together with position gives me the same Galaxy with the same Galaxy seed every time. I could potentially do a 3D cube of stars and check each cubic light year, then randomly locate a star within that lyr^3. So for Galaxy 731 I could warp to a hundred lyr cube at 5300 by 11300 by -100 lyr and quickly check 5332 by 11321 by -123. If it exists, I can further use randomness generated from the seed for that location to place it at 5333.31 by 11321.53 by -123.02
@michaelburns8073
@michaelburns8073 4 жыл бұрын
Okay, you were already a god for doing the NES series, but now, you're just proving it. :-)
@vincentcleaver1925
@vincentcleaver1925 2 жыл бұрын
I hope you guys are doing well. I have not seen much going on with the channel, but I know you have the baby and work. Thanks!
@zxzxzxzPDOGZzxzxzxz
@zxzxzxzPDOGZzxzxzxz 4 жыл бұрын
This is awesome, gave me a lot of inspiration for projects!!
@MrVinhPhan
@MrVinhPhan 3 жыл бұрын
I think it is wrong to think Minecraft automatic generated because the reason why it store it's chuck because the player interact with those chunk so it need to note down what has changed. With the same seeds, Minecraft can recreate the exact copy of the world just like the one you have here.
@tomtech351
@tomtech351 4 жыл бұрын
Just discovered your channel and this was the first video I’ve watched. Awesome stuff, definitely interested in the universe “persistent state” and modifications you alluded to at the end. Now to go back to some of your earlier stuff. I’m not a c++ man so will need to jump a few steps back now
@Mario-vt2ss
@Mario-vt2ss Жыл бұрын
Thanks for sharing your ideas, this is great example. One could also generate names of stars and planet with same idea.
@styleisaweapon
@styleisaweapon 4 жыл бұрын
What you want is a hash function, or even a set of hash functions, not an RNG. The technique is to hash the "key" value (your coordinates, for example) and use the bits of the hashed result for your "randomness." You don't need a crypto-strength hash either.
@rawrxd1566
@rawrxd1566 4 жыл бұрын
You just created No Man's Sky XD
@stryyker9
@stryyker9 4 жыл бұрын
The Internet Historian is watching
@pastamarter6084
@pastamarter6084 4 жыл бұрын
Or Space Engine ;)
@ShadowGaro
@ShadowGaro 4 жыл бұрын
When procedural generation goes too far lol
@seireiart
@seireiart 4 жыл бұрын
So that's how the 96KB game was made. Interesting
@jakoblarsen9526
@jakoblarsen9526 4 жыл бұрын
Yet another interesting video. My initial thought was perlin noise and now just learned about Lehmer as well ;)
@javidx9
@javidx9 4 жыл бұрын
Thanks Jakob, there is no "standard" way of approaching procedural generation, you just need to think about construction a little differently
@QubaMichalski
@QubaMichalski 4 жыл бұрын
Rand was actually twice slower than the later generators! 0.006 vs 0.003. Awesome video. If you love Elite - consider trying it with a head tracker (or high res vr)
@Galileo51Galilei
@Galileo51Galilei 4 жыл бұрын
This is extremely interesting and fascinating content. I enjoy a lot that restrictive definition of procedural generation, it carries elegant design ideas. I wanted to know more about this subject, so, thank your very much for that
@javidx9
@javidx9 4 жыл бұрын
My pleasure Galileo!
@ristopoho824
@ristopoho824 4 жыл бұрын
I'm actually making a game with this as a premise. I wanted a huge world, with the player being able to change some things in some places, but creating each effect by hand would be just about impossible. So i implemented a similar'ish' method to calculate the effects each time the vicinity is loaded. It's still a work in progress, so much that i won't make any part of it public, but maybe someday.
@jonathancamarena3117
@jonathancamarena3117 4 жыл бұрын
Thank you for this ! I took what you taught here and translated it to rust. I havent actually used it for anything but it was a fun exercise!
@brianmac8260
@brianmac8260 4 жыл бұрын
Top notch as always. Thanks Jx9.
@SunSailor
@SunSailor 2 жыл бұрын
Actually, the C64 was capable of real random numbers by its analogue part of the SID. This little machines still know to amaze, even today :)
@GregoryTheGr8ster
@GregoryTheGr8ster 4 жыл бұрын
Some people can draw near-perfect circles on chalkboards; but at 19:36, it appears that other people can draw near-perfect Gaussian curves instead. With a little practice, you could be one of them!
@roamingcelt
@roamingcelt 6 ай бұрын
Thank you. You just gave me the idea of adding pixels to my custom vector class. (eg v+px or v+=px)
@steveymcneckbeard
@steveymcneckbeard 4 жыл бұрын
How am I only just finding your channel?! Many thanks for sharing your knowledge.
@ShadowGaro
@ShadowGaro 4 жыл бұрын
Excellent video. You briefly touched on gaussian distributions but I'd like to expand on it. You can actually very easily create gaussian distributions by summing multiple random numbers. For example rand(6)+rand(6) will have a maximum of 10, a minimum of 0, but values will concentrate around the middle. In some cases this can be more realistic, for example heights of humans. You can also create unbounded distributions. Consider the following code: int nMoons=0; while (rand(2)==0) ++nMoons; There's a 50% chance of no moon, 25% chance of 1 moon, 12.5% chance of 2, 6.25% chance of 3, and so on to infinity. As you explore you will find planets with more and more moons, and even the developer won't know what planet has the most moons unless he writes code to search for it.
@javidx9
@javidx9 4 жыл бұрын
Thanks Garo! Yeah, Im sure statisticians/probability enthusiasts can have hours of fun tinkering with the constructions XD
@MasterOfMisc
@MasterOfMisc 4 жыл бұрын
Awesome. Now I can understand how No Mans Sky was developed (which is an awesome game by the way). Looking forward to this one.
@JamesNewton
@JamesNewton 4 жыл бұрын
A few random ideas: - Procedurally generate short strings of words (extracted from a dictionary), then use those words to search google images, and display the top image as the background of the players position in a game. For consistency, prepend a constant or pre-generated sequence. e.g. "'New York Street' scarf tram baby", "'New York Street' blob accountant time" - As above, but use a restricted dictionary of things like texture names, or peoples names, or other elements of a game. - As above, but use those as a prompt into GPT2. - Use the seed as a lat long, limited to a high population area (e.g. NY, LA, etc...) and then convert that into a street address, and use that as a prompt into GPT2. The point, in general, is to use apparently random values (but which are actually procedural seeds) as prompts into real world databases.
@michaelmahn4373
@michaelmahn4373 4 жыл бұрын
Reminds me of Master of Orion, but I've never played Elite. Nice! Makes me wish to explore that universe. :-)
@Mazered20
@Mazered20 4 жыл бұрын
For my project i had to use random to know where flowers should be, it was the same as with your planets I used a hash library called xxhash, because it's very fast, and i can hash the seed and the output will be consistant, and looks like random!
@sollder1240
@sollder1240 3 жыл бұрын
That is absolutely amazing, I love Math and ComputerScience exactly because of stuff like that!
@zemlidrakona2915
@zemlidrakona2915 4 жыл бұрын
Ha! You just solved my tree placement problem on my procedural world. Thanks!
@NoahtheEpicGuy
@NoahtheEpicGuy Жыл бұрын
I once wrote a "less random" random (something like Perlin or Simplex, where a small change between input values facilitates a small change in the output) in Blitz3D by using the seed. It would get the random values at each corner of a cell (by seeding using the X and Y of that cell) and then linearly interpolate inbetween them. It was an interesting approach, and it worked pretty well for the purpose of a game written in Blitz3D. In C++, I'm guessing rand() stores the old seed, randomizes the seed and stores it, and then returns the old seed. It'd probably work after another call to rand(), but that'll essentially halve performance. Of course, half is relative. However, I think at that point, you might as well just copy the random generator code and have the seed be a constant value that's combined with the X and Y bits. That's how I would approach spatially-consistent (if that's even a term) randomness at a low level with pretty good performance. Distribution should be good (if the core RNG routine is also pretty good) but gradient leaves room for imagination, but you can solve it with what I did in Blitz3D.
@guillermogarciamanjarrez8934
@guillermogarciamanjarrez8934 4 жыл бұрын
That cliffhanger though, really looking forward for the next video on this topic
@paulolellis5708
@paulolellis5708 3 жыл бұрын
Thanks you for sharing. Your code worked like a charm with the new M1 arm64 processor!
@kiro_f
@kiro_f 4 жыл бұрын
i mean, minecraft can consistently generate terrain, it stores the data so that players can edit the world
@Domarius64
@Domarius64 4 жыл бұрын
Exactly. And if he wants to do anything useful in his universe, he'll have to do the same.
@PetrPss
@PetrPss 4 жыл бұрын
Yeah. Didn't get the difference either. If you somehow disable storing world data on disk, only visible chunks will be stored (in RAM!). Just like in this video. I guess olc just hates Minecraft :)
@Domarius64
@Domarius64 4 жыл бұрын
@@PetrPss I made a post saying exactly that, no response. Lots of hearted comments singing his praise though XD
@MagicGonads
@MagicGonads 4 жыл бұрын
Because minecraft actually stores the chunks you load in a world file, whereas likely he is going to talk about storing difference maps, that is, only storing what is *different* since generation. Basically, I have *the entire universe* and I made a hole over here, I just store that hole and use the information about that hole when it's relevant. But to do that requires more processing power than is probably optimum, since disk space is cheap, minecraft just opts to store everything that the player has seen. Storing it like minecraft does also makes it consistent with updates to world generation. Let's say I change my global seed subtly or maybe the algorithm that chooses the seed or the random algorithm itself, the difference map would now be incorrect because the fundamental universe underlying it is different. (the hole I made could appear inside a completely different planet, or, might not even be encoded correctly as a hole) But in minecraft, you will only get such discrepancies when you encounter new terrain, where there is no difference map so the issue is that the new terrain will be generated in a different way to how the old terrain was.
@Domarius64
@Domarius64 4 жыл бұрын
@@MagicGonads it's certainly a valid approach.
@laureven
@laureven 4 жыл бұрын
I use 480p to save bandwidth and in this video, it was fun to watch how youtube is struggling to compress the video :). super fascinating subject, but still I'm lacking some c++ knowledge to fully understand the code, but every day less and less. Regards everybody
@dreamyrhodes
@dreamyrhodes 4 жыл бұрын
This is a great tutorial even if I am not a C++ coder but I can use the principle in other languages. To have it even more similar to Elite Dangerous, one could now generate a state that a system is in, like War, Boom, Civil Unrest, Outbreak, Attacked by Thargoids ect, just by adding a timestamp to the seed of the rnd, let's say yymmdd12:00 so each day at 12:00 the state would change and you could even calculate back what state the system was in like 5 days ago (you could also determine what state the system would be in in the next 5 days but that'd be cheating ;).
@SuperNolane
@SuperNolane 4 жыл бұрын
Linux provides /dev/random which is a virtual device providing truly random numbers. The system uses every random thing it can to generate these numbers and turns out there's not much randomness inside computers. Common sources of randomness are voltage in circuits and user input. These are very slow sources so is the generation of truly random numbers. The funny thing about it is that if you provide enough input, by moving cursor for example, /dev/random becomes noticeably faster.
@samdavepollard
@samdavepollard 4 жыл бұрын
You, Sir, are possibly the geekiest geek I ever encountered. (That's intended as a compliment by the way. Many Thanks for sharing your knowledge.)
@jsflood
@jsflood 4 жыл бұрын
Awesome! This is pure "void opals"! Great video, I have been waiting for this one my whole life :-D Thank you!
@javidx9
@javidx9 4 жыл бұрын
Sigh, another ED cheater... 100cr bounty on this guy fellas.... XD
@jsflood
@jsflood 4 жыл бұрын
Only 100cr? You are too generous :-D
@FPS-007
@FPS-007 5 ай бұрын
You should extend this example at some point, I would love to see how you handle seeds for stuff generated on a planet. like give them each a world map of countries, each with information about them, then you can view cities in that country, then buildings in each city, rooms in each building, characters in each room.
@YumanoidPontifex
@YumanoidPontifex 4 жыл бұрын
i've been a fan of elite since i got hooked on the zx spectrum version in the early 90s. i also spent some time on elite: dangerous in recent years, though not active anymore. and although i always knew what procedural generation was, this is still a very enlightening video.
@spaarks84
@spaarks84 4 жыл бұрын
Nice video. Minecraft uses proper procedural generation however. So does an awesome Roguelike called "Noita". Terraria used something like the "automated generation" which you described.
@lightningshark67
@lightningshark67 4 жыл бұрын
Has anyone else found the random double code at 25:18 to be inaccurate? It may a typo or something I've done wrong in writing it out. But, it tends to return values that are over the max. For example, getting values between 0.0 and 1.0 returned several values over 1.0 (Even as high as 1.99, 1.8, etc).
@matthewgrotke1442
@matthewgrotke1442 4 жыл бұрын
11:55 An cheap hack would be to use the least significant bits of CPU temperature and voltage, if you can get a precise measurement. I know there are some specialty entropy sources, which are basically PCI cards that contain a small amount of radioactive material and a Geiger counter. The timing of radioactive decay is truly random, unless you're one of those people that think the universe is deterministic, but in that case it is still as random as is physically possible to be.
@TheHighlander71
@TheHighlander71 4 жыл бұрын
I've travelled to many systems in Elite:Dangerous. The systems in this video actually remind me of that.
@TackerTacker
@TackerTacker 4 жыл бұрын
I disagree with your definition of procedural generation at the start of the video ... or maybe only with the given examples. Minecraft does procedurally generate it's world, it only needs to store the information to save the changes made in a chunk, it will always generate the exact same initial world state given the same seed and version of the game. It's not just random and needs to be saved to be persistent, if that would be the case then i would agree with you, but neither Minecraft nor most modern rogue likes work this way. Most, if not all of the ones i know, can perfectly recreate the whole world/dungeon based on nothing more then the seed and a location, for every player in the exact same way. Daily runs are a popular thing in modern rogue likes and they stem from the fact that every player will generate the exact same level just by using the same seed, so developers only need to define a daily seed so that every player can run the same level and competing for the daily highscore.
@TackerTacker
@TackerTacker 4 жыл бұрын
@FichDichInDemArsch Could you please elaborate on that?
@SmashHighlights
@SmashHighlights 4 жыл бұрын
I'm pretty inspired by this. Great video!
@javidx9
@javidx9 4 жыл бұрын
Thanks!
@cmdr_thrudd
@cmdr_thrudd 4 жыл бұрын
What a nice calm and informative video. o7
@yogxoth1959
@yogxoth1959 4 жыл бұрын
The thumbnail reminded me of Elite Dangerous!
@RamHomier
@RamHomier 4 жыл бұрын
Pokerstars has a pretty nice video about their random number generation. It seems pretty much perfect at a quantum physics level.
@iProgramInCpp
@iProgramInCpp 4 жыл бұрын
Awesome job describing the algorithms!
Coding Quickie: Isometric Tiles
22:13
javidx9
Рет қаралды 119 М.
How does procedural generation work? | Bitwise
13:48
DigiDigger
Рет қаралды 394 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Brute Force Processing
52:50
javidx9
Рет қаралды 156 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Stop using std::vector wrong
23:14
The Cherno
Рет қаралды 158 М.
When Optimisations Work, But for the Wrong Reasons
22:19
SimonDev
Рет қаралды 1,1 МЛН
Quirky Quad Trees Part1: Static Spatial Acceleration
44:01
javidx9
Рет қаралды 71 М.
EA Won't Let Me Play This Game - So I Hacked It
8:49
Nathan Baggs
Рет қаралды 329 М.
His Wife Threw his Gaming PC out the Window… Can I Fix It?
19:43
Linus Tech Tips
Рет қаралды 799 М.
Why Can't We Make Simple Software? - Peter van Hardenberg
41:34
Handmade Cities
Рет қаралды 163 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН