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
 

Re: math.randomseed(tick())

Previous Thread :: Next Thread 
iDerpyDogez is not online. iDerpyDogez
Joined: 05 Feb 2012
Total Posts: 1781
27 Jul 2016 02:40 PM
what does it do?
i dont even know what randomseed does in the first place lol


blobfish are going to be bricks for my wall; tardigrades are going to be the glue for my wall
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
27 Jul 2016 02: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
iDerpyDogez is not online. iDerpyDogez
Joined: 05 Feb 2012
Total Posts: 1781
27 Jul 2016 02:43 PM
oh, and the %1*1e7 thing some people do is so that its random even if its almost at the same time?


blobfish are going to be bricks for my wall; tardigrades are going to be the glue for my wall
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
27 Jul 2016 02:45 PM
People who do that don't really know what they're doing. the only reason that would ever be useful is if you're calling tick() multiple times in the same second(and expecting a different response), which you should never be doing in the first place.
Report Abuse
iDerpyDogez is not online. iDerpyDogez
Joined: 05 Feb 2012
Total Posts: 1781
27 Jul 2016 02:46 PM
oh, okay thanks


blobfish are going to be bricks for my wall; tardigrades are going to be the glue for my wall
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
27 Jul 2016 02:47 PM
Certainly not true. If you have two servers start in the same day, the first map will probably be the same on each server.


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