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: Is math.random actually random?

Previous Thread :: Next Thread 
ninja5566 is not online. ninja5566
Joined: 14 Jan 2009
Total Posts: 5233
02 May 2014 12:48 PM
A lot of the professional scripters say that it's not actually random, they said you should use getAsync on a website called "Random", is this true?

Report Abuse
zbaddude2 is not online. zbaddude2
Joined: 12 Dec 2009
Total Posts: 1897
02 May 2014 12:54 PM
Yes binary computers are actually incapable of giving completely random results. Only quantum computers can do this.
Report Abuse
ninja5566 is not online. ninja5566
Joined: 14 Jan 2009
Total Posts: 5233
02 May 2014 12:57 PM
Interesting
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
02 May 2014 01:13 PM
"they said you should use getAsync on a website called "Random", is this true?"

They are wrong, you should absolutely not be going to such lengths as using Random.org for your number generation. math.random is very much "random enough" for whatever you want to use it for on Roblox.

Yes, it's a pseudo-random number generator, meaning that you can predict it if you know how it's implemented and seeded, but unless you really care about someone who put in many hours of work being able to reverse engineer what "random" poker hands their opponents have been dealt in a poker game then you don't need to worry about math.random not being "random enough".
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
02 May 2014 02:00 PM
Seeding with tick() or some other simple non-deterministic time (perhaps of execution rather than clock) is more than sufficient even, really, for many crypto purposes.

Doing calls to a web service is completely unnecessary.

Besides all of this, you don't need true randomness for a ROBLOX game. The only things that need it are cryptographic solutions and fair casino / tournament generation schemes, and even then the more important thing is generation method rather than seed.
Report Abuse
AMasterProgrammer is not online. AMasterProgrammer
Joined: 02 Apr 2013
Total Posts: 1608
02 May 2014 09:41 PM
technically nothing can be random right? everything has a cause and effect and you can predict that effect if you have enough info about the cause.
Report Abuse
zbaddude2 is not online. zbaddude2
Joined: 12 Dec 2009
Total Posts: 1897
02 May 2014 09:43 PM
No quantum computers can generate truly random numbers.
Report Abuse
Maroy is not online. Maroy
Joined: 15 Mar 2009
Total Posts: 59
02 May 2014 10:56 PM
Quantum mechanics rely on probability, though, so even then it's still biased randomness.
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
03 May 2014 12:46 AM
So what if you did math.randomseed(math.random())?
Report Abuse
MettaurSp is not online. MettaurSp
Joined: 20 Mar 2010
Total Posts: 3179
03 May 2014 12:49 AM
It still wouldn't be entirely random because there still is a seed that is used in setting the seed.
Report Abuse
AMasterProgrammer is not online. AMasterProgrammer
Joined: 02 Apr 2013
Total Posts: 1608
03 May 2014 02:31 AM
y r u people police men
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
03 May 2014 07:03 AM
It's funny, because people think that it will get more random the more you seed. This is completely false. In fact, it's so false that it's actually the opposite. It will get LESS random, the more you seed. The way to do it properly is this:

math.randomseed(os.time())
math.random()
math.random()
math.random()

You just seed the time, and then you call math.random 3 times, because you will find that there are these patterns right after you seed. So if you seed 5, call random, you might get a very similar number to if you seed 10 and call random. But after about 3 calls, that "pattern" disappears.
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
03 May 2014 02:41 PM
Here is the source code for math.random if anyone is interested hurr durr

static int math_random (lua_State *L) {
/* the `%' avoids the (rare) case of r==1, and is needed also because on
some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX;
switch (lua_gettop(L)) { /* check number of arguments */
case 0: { /* no arguments */
lua_pushnumber(L, r); /* Number between 0 and 1 */
break;
}
case 1: { /* only upper limit */
int u = luaL_checkint(L, 1);
luaL_argcheck(L, 1<=u, 1, "interval is empty");
lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */
break;
}
case 2: { /* lower and upper limits */
int l = luaL_checkint(L, 1);
int u = luaL_checkint(L, 2);
luaL_argcheck(L, l<=u, 2, "interval is empty");
lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */
break;
}
default: return luaL_error(L, "wrong number of arguments");
}
return 1;
}
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