sup everyone its Bucky and welcome to your thirteenth tutorial and see and in this story I'm going to be showing you guys how to make a truly random number generator and you guys are saying alright didn't teach us that last time well I did but well you'll see this is a little surprise in store for you now just to tell you guys pretty much what I'm gonna do let's go ahead and first let's execute and run this program now the truth behind computer random number generators is that a computer is only a computer there is no way in the world that computer can truly generate a random number since it has to follow a pattern it's just made up of a bunch of electronics it has to be told exactly what to do so whenever we build a basic a random number generator although these look like random numbers is actually following a very precise algorithm to develop these random numbers so if you see 41:18 thousand six thousand twenty six thousand and then you go ahead and run this again it's gonna follow that exact same algorithm again which is pretty random but the algorithm is the exact same set of random numbers forty eighteen thousand six thousand twenty six thousand exactly like before and this is pretty much supports the fact that there is no way you can tell a computer to generate random numbers it doesn't have a brain it can't pick it off the top of its head so it has to follow the circuits in whatever it does to follow distinct pattern so as you can see or I say that don't I or what I'm trying to say is this is not a really desirable thing we want so the closest thing we can do is trick the computer or at least not letting a human being able to predict the random number of the computer and if we say all right what's so bad if the humor can predict it well let's say you're building like a slot machine for a casino and see and you really don't want to human to predict that or if you're building a game or anything so to do this we need to start at a new value every time and to do this again I said that I feel like repeating myself today we need to make something called a seed now when you seed a random number it gives it a new value instead of the old algorithm it's used to in the seed or random number is s ra ND this means seed random and what this line of code does right here is whatever parameter you type in this can be any number it's going to use that value and input it somehow into its algorithm to generate a list of truly random numbers so let's say let me just put 12 just because the one and two are close to each other and I'm lazy and as you can are I'm gonna stop saying that you got 40 last time than like I can't remember what it was but it started with 41 now you see it starts with 77 and gives you a whole list of random numbers so that's what seeding a random number does but the problem with this is it doesn't just work all the time when you see a random number again I ran this program once more and it gave you the same list of numbers what's eating a random number does is take this and use it as a variable in the algorithm so it changes it up a bit but it still doesn't change it so it's totally unique each time so it just pretty much gives you a different algorithm so how can we seed a number that changes every time the computer runs the program well to do that we need to think for a second what is a value that we can put in here to have it change every time we could have the we could put a scan that variable in there and have the user type it but we really don't want that that's not be useful so the only thing that I can think of that changes every single second is time so let's go ahead and write our time variable in our parameter for our seed variable so to do that go ahead and put time and in your parameters go ahead and put null because you don't want it to have any variables and what this will do is this it'll take the time which is is it's actually a number in how many seconds since like January first so many years ago this is actually a number that changes every second and it's going to take it and put it in your entire seed variable so this is gonna pretty much take a random variable and throw into this entire random number generator algorithm so me you or no one knows exactly what number it is so this is how let me separate this so you can see is how you use time which is ever changing variable you don't have to worry about it and insert it into your seed so you can have a truly random number generator so let me go ahead and show you guys gonna go ahead and compile this and the first time we run it we get nine thousand eight thousand nine thousand ten thousand now let's go ahead and run it again and if this worked out perfectly they should be different and come on so we got nine thousand uh-oh that's what we started last time sixteen thousand twelve thousand twenty eight thousand nice so that is how you build a truly random jump jump enumerator what number generator jumper numerator uh correct myself up so again that is how you do that by using a seed with your time parameter to seed a variable in your random number generator so again study this tutorial practice it have some fun with it both programmed rolled dice or something like that do something fun it and again I just want to thank you guys for watching don't forget to subscribe to my channel again thank you and I'll see you next time