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

Previous Thread :: Next Thread 
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
11 Nov 2017 06:15 PM
try it out

btw, pls fix Roblox

the only fix I see to this is doing a for loop

this fix works but the true Random Number's max range has to be big
so it causes a little bit of lag:

for i=0,trueRandomNumber do
math.random()
end


Report Abuse
Luo_Basics is not online. Luo_Basics
Joined: 20 Jan 2014
Total Posts: 5752
11 Nov 2017 06:15 PM
learn how to use math.random and it wont be broken


if (dev.ShouldLearnNewLanguage){dev:LearnJS()}
Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
11 Nov 2017 06:16 PM
I found out it doesn't work when making a random death message thing for my game, Everland


https://www.roblox.com/games/791614285/Everland


Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
11 Nov 2017 06:23 PM
@Luo_Basics

I know how to use random math

math.random(min,max)

it's not that hard

The reason I called math.random() without any variables is because random math uses this really complex equation to generate random numbers. Every time you call math.random(), it uses the number generated to make a new random number for the next time you call math.random

this fix isn't very good because of many reasons, but idk what else to do
1. it lags
2. if the true random number's max is too small, it has a chance to repeat itself
3. if the true random number's max is too big, it has a chance to crash the script


Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
11 Nov 2017 06:31 PM
btw about that mini-fix, you might want to wrap that in a spawn() incase it crashes

that way your entire script doesnt crash



spawn(function()
for i=0,trueRandomNumber do
math.random()
end
end)


Report Abuse
Luo_Basics is not online. Luo_Basics
Joined: 20 Jan 2014
Total Posts: 5752
11 Nov 2017 06:34 PM
roblox already sets the randomseed.

"math.random(min, max)"
no


if (dev.ShouldLearnNewLanguage){dev:LearnJS()}
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
11 Nov 2017 06:36 PM
Anything can be broken to somebody that doesn't know how to correctly use it.
Report Abuse
Scrippa is not online. Scrippa
Joined: 25 Dec 2011
Total Posts: 20289
11 Nov 2017 06:37 PM
how would it even break, why would roblox edit it or do anything that could possibly broke it, it's a feature that always worked, you must b doing something wrong





Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
11 Nov 2017 06:44 PM
Roblox sets one randomseed for every game
I want different random numbers for every server
if you don't set the randomseed, it will keep giving you the same "random" numbers on a new server

http://wiki.roblox.com/index.php?title=Random_numbers

more about it here ^
I'm doing it correctly.
I even went as far as to find an api online to get random numbers for me.
I should probs go back to using tick() instead tho now that I know it isn't the fault of the random number not being random enough.....


Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
11 Nov 2017 06:47 PM
I don't know why it is not working

Try it yourself before you tell me I don't know what I'm doing


When I say I got true random numbers online, I mean I got true random numbers online to set the randomseed


Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
11 Nov 2017 06:52 PM
Also, I would like to say that you can do math.random(min,max) in Roblox lua

Unlike in Java or JavaScript where you have to do stuff like
Math.random() * (max - min) + min;


Report Abuse
leafyyeah is online. leafyyeah
Joined: 25 Nov 2016
Total Posts: 104
11 Nov 2017 07:11 PM
There is no way it is broken,

The Only way to fix this issue is to "Retry your script"
Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
11 Nov 2017 11:53 PM
Have any of you even thought of the possibility that I might be right?

Out of everyone that is telling me to retry my script, how many of you have actually tried doing this in studio?


Report Abuse
Shining_Diamando is not online. Shining_Diamando
Joined: 11 Oct 2014
Total Posts: 460
11 Nov 2017 11:59 PM
You're wrong.

math.randomseed(tick())

for i = 1, 10 do
print(math.random(0, 9))
end

Will always produce different results in a live server.
Studio plugins use math.randomseed (terrain ones) so it'll appear that the seed is always the same.
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
12 Nov 2017 12:03 AM
math.randomseed is not broken. Its functionality hasn't changed.

If you want to see why you're getting the same results, then read this:

http://wiki.roblox.com/index.php?title=Random_numbers
Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
12 Nov 2017 12:08 AM
I have retried my scripts.

I have tested this in game.

I literally linked that same article.

I don't link articles before I read them.

Im telling you, it is broken.


Report Abuse
Horrible_Pun is not online. Horrible_Pun
Joined: 13 May 2017
Total Posts: 5102
12 Nov 2017 12:15 AM
oh my gosh😅😅😅 you are using it wrong
Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
12 Nov 2017 12:17 AM
"There are 2 wa#s#### can make the random number generator generate different numbers every time the place runs:

call math.random a random (from real-life influences) number of times
Seed the random generator with a different number whenever the game runs
If you can find a way to make something truly random influence any of the two listed items, then you will be able to generate different numbers every time the game runs.

math.randomseed[edit]
The best way to fix this problem is setting the seed of math.random() with the function called math.randomseed().

The problem is finding a good seed. One option is to use tick(). This returns the number of seconds elapsed since UNIX time (1/1/1970 0:00:00).

To use it, simply pass the result of tick() to math.randomseed.

math.randomseed(tick())"
- http://wiki.roblox.com/index.php?title=Random_numbers



wow they used the same method I thought up of in the article

I wonder why they would include 2 methods to make math.random random?
>:T



Im telling you this is broken.
This might be a serious issue

This might be exploitable in games that use this


Report Abuse
Chrounum is not online. Chrounum
Joined: 04 Apr 2015
Total Posts: 2911
12 Nov 2017 12:26 AM
stop


#code print("don't forget to dry the towel after use")
Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
12 Nov 2017 12:39 AM
If you have nothing helpful to say, don't say it at all

As of November 12, 2017, math.randomseed is broken.

Try it out yourself before saying anything.
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
12 Nov 2017 12:39 AM
It works fine if you know how to use it.
Report Abuse
Horrible_Pun is not online. Horrible_Pun
Joined: 13 May 2017
Total Posts: 5102
12 Nov 2017 12:40 AM
Works completely fine for me.
My code:

math.randomseed(tick())
print(math.random(1,10))
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 Nov 2017 02:31 AM
"math.randomseed is broken"
In what way is it "broken"?

"because random math uses this really complex equation to generate random numbers."
Actually no. Internally it uses a linear congruence generator which is really just multiplication and addition followed by bit masking. It's really not slow.

"1. it lags"
No

"2. if the true random number's max is too small, it has a chance to repeat itself"
Believe it or not, it would be not random if it didn't repeat itself.

"3. if the true random number's max is too big, it has a chance to crash the script"
No

"Roblox sets one randomseed for every game
I want different random numbers for every server"
It's per server not per place.


You clearly do not understand how pseudo random number generators work. Here's a tip, don't immediately blame the language. Blame yourself.

On another note, LCGs are really trash and very predictable, so see this: https://devforum.roblox.com/t/a-better-random-number-generator/57990
Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
12 Nov 2017 06:29 PM
@cntkillme

'In what way is it "broken"?'

math.randomseed isn't randomizing math.random()





'Actually no. Internally it uses a linear congruence generator which is really just multiplication and addition followed by bit masking. It's really not slow.'

That's basically just a really complex equation.
I never said it was slow.





'No'
'Believe it or not, it would be not random if it didn't repeat itself.'
'No'

First off, that list of problems was directed at my fix, not Roblox's random math system. I can see how you could have gotten confused by that and apologize for not making it clearer.

Second, when I say it has a chance to repeat itself, I'm saying the same "random" numbers would appear in the same sequence on one server as it did on another server.





'It's per server not per place.'

As tests I have personally done and the official Roblox Wiki says,
It is per place not per server.

"There is a random number generator in Roblox that seems to generate random numb######## ###a test, and insert this script into your place:

for _ = 1, 10 do
print(math.random(100))
wait(1)
end
Test the place, and look at the output window. Write down the numbers you get, and exit the test. Then do the test again, and again write down the numbers you get. Notice something weird? Those 10 very random numbers are similar everytime you run a test (or play online for that matter)."

- Roblox wiki

http://wiki.roblox.com/index.php?title=Random_numbers





'You clearly do not understand how pseudo random number generators work. Here's a tip, don't immediately blame the language. Blame yourself.'

I didn't immediately blame the language.
I'm not a noob.

I've done various tests.

I feel that this is a misunderstanding and strongly urge you to run some tests of your own before completely discrediting me.

Also, reading this entire forum would help.
Or at the very least, all my replies.



Report Abuse
dispeller is not online. dispeller
Joined: 11 Dec 2016
Total Posts: 332
12 Nov 2017 06:39 PM
@Horrible_Pun

Did you test it on the actual game or on studio?
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