generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

What is math.randomseed()?

Previous Thread :: Next Thread 
Holy_Doge is not online. 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 is not online. 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
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
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 is not online. 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 is not online. 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
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
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 is not online. 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
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image