Holy_Doge
|
  |
| Joined: 08 Feb 2012 |
| Total Posts: 1968 |
|
|
| 26 Jul 2016 04:33 PM |
I keep seeing but I have no idea what it means
The wiki said "it sets the seed for the random number", but what does that mean?
|
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 26 Jul 2016 04:38 PM |
| Exactly what it says. It's a magical value that determines how the random numbers are generated. Same seed = same numbers. |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2016 04:38 PM |
I don't know how it works, but you'd do this: math.randomseed(tick()) print(math.random(1, 10))
( ͡• ◡ ͡•) -=[ RAP: 363,856 || DurstAuric; the narb of ROBLOX ]=- ( ͡• ◡ ͡•) |
|
|
| Report Abuse |
|
|
Holy_Doge
|
  |
| Joined: 08 Feb 2012 |
| Total Posts: 1968 |
|
|
| 26 Jul 2016 04:39 PM |
So basically math.randomseed() sets the base for all random numbers
|
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 26 Jul 2016 04:41 PM |
Pseudo-random number generators (such as Lua's math.random function) use a seed to generate a random number as it is impossible for computers to generator a 'true' 100% random number.
The seed used for random number generation is basically a number to 'base' the random number on. If you use the same seed, you will get the same numbers.
For example:
math.randomseed(tick()) --sets the randomseed to local UNIX time (number of seconds since Jan 1, 1970), which will generally always be different unless you're calling it multiple times in the same second print(math.random())
Run the above code a few times and you will most likely get different numbers
math.randomseed(1) print(math.random())
Run this code, however, and you will see the same number every time because it is basing the random number generated on the seed. Since the seed is always 1, it will always get the same number. You can also do this:
math.randomseed(1) print(math.random()) print(math.random())
And the second number will be different from the first, but each time both numbers will be the same.
This can be useful when using procedural generation to randomly generate worlds for the player to play in. Allowing the player to specify their own seed means if they generate a world they really like they can use that same seed and they will get the same world again.
|
|
|
| Report Abuse |
|
|
|
| 26 Jul 2016 04:43 PM |
it returns a random seed
every seed has a different set of numbers
if you did math.random with a seed of 2 you would get the same number order
randomizing your seeds ensures math.random never returns the same order of numbers
Add 13,000 posts |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 26 Jul 2016 04:45 PM |
>"it returns a random seed" It returns nothing
>"randomizing your seeds ensures math.random never returns the same order of numbers" 'randomizing' your seed will do nothing Two different seeds CAN allow for math.random to return the same order of numbers, however unlikely. If that weren't the case it would be even less random. |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2016 04:51 PM |
well kodran
that's useful info
good thing u posted before me
don't want op to get the wrong idea
Add 13,000 posts |
|
|
| Report Abuse |
|
|