|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|