|
| 14 Jun 2016 02:04 PM |
Math.random is random, but its predictable; too predictable. Is there a way to make math.random more "random" and never select the same result twice (or more) in a row?
-=[ RAP: 314,296 || DurstAuric; the narb of ROBLOX ]=- |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 02:05 PM |
put math.randomseed(tick()%69*1337/420) at the top of your script
not even joking
#code R+ | local RAP = "R$606,782"; local robux = "R$4,167" |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 02:05 PM |
math.random() returns a random number between 0-0.5
You can multiply that if you want. It'd probably be more random
|
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 02:09 PM |
@Abstract Lolwhat?
-=[ RAP: 314,237 || DurstAuric; the narb of ROBLOX ]=- |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 14 Jun 2016 02:13 PM |
math.randomseed(tick()) at the beginning of your code is the only thing you need for a true-enough random
This seeds math.random based off time, which is a great reference for randomness
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 14 Jun 2016 02:15 PM |
Abstract's %69*1337/420 will have virtually the same effect
all those numbers mean virtually nothing tho :)
>"virtually" intensifies
|
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 02:15 PM |
"math.randomseed(tick()) at the beginning of your code is the only thing you need for a true-enough random"
that gives you an even more predictable random |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 14 Jun 2016 02:28 PM |
Uhh duurrr so is math.randomseed(tick()%69*1337/420)
|
|
|
| Report Abuse |
|
|
membra
|
  |
| Joined: 14 Oct 2008 |
| Total Posts: 6313 |
|
|
| 14 Jun 2016 02:29 PM |
I've seen a few people fetch random numbers via random dot org using HTTP. I'm not sure if that's a smart thing to do, though.
|
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 03:09 PM |
@Membra And how would I do that exactly?
-=[ RAP: 314,087 || DurstAuric; the narb of ROBLOX ]=- |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 14 Jun 2016 03:10 PM |
It's not even worth it
just randomseed(tick()) bro
|
|
|
| Report Abuse |
|
|
LuaLlama
|
  |
| Joined: 25 Jan 2014 |
| Total Posts: 1123 |
|
|
| 14 Jun 2016 03:12 PM |
math.randomseed(tick()*math.random()) -- This proves that Math.random() returns a double value between 0, and 1
That might be the best way. |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 03:15 PM |
Okay. If anyone is wondering, I'm using this in order to create an in-game music player which plays a random song from a table, rather than in order. From experience, math.random isn't exactly "random" so I needed a way to make it more random..
-=[ RAP: 314,061 || DurstAuric; the narb of ROBLOX ]=- |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 03:15 PM |
or
math.randomseed(math.random(os.time())) |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 03:28 PM |
I don't think there's a difference if I use math.randomseed(math.random(os.time()) compared to math.randomseed(tick()).
-=[ RAP: 314,051 || DurstAuric; the narb of ROBLOX ]=- |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 03:32 PM |
"put math.randomseed(tick()%69*1337/420) at the top of your script" That literally makes it worse
"math.random() returns a random number between 0-0.5" No. Between 0-1 exclusive
"math.randomseed(tick()) at the beginning of your code is the only thing you need for a true-enough random" IIRC Roblox already sets the seed to this when a server starts so it won't really make an actual difference. The algorithm for fetching a random number will always be the same
OP if you really care about "true randomness" then use HttpService and fetch from random dot org or soemthing. |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 03:39 PM |
math.randomseed(tick())
local songNum = math.random(1,100)--change
Songs[songNum]:Play()
function check() local oldNum = songNum repeat songNum = math.random(1,100) until songNum ~= oldNum end
Sloppy, but this is the general idea. |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 03:42 PM |
| That's not how random works. That makes it less random. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 14 Jun 2016 03:45 PM |
Does true randomness even exist? Are my actions random? Do I have free will?
AHHHH
|
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 03:46 PM |
| @Flux curse you randomness. You think it's the easiest subject to understand until you start studying it. |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 03:52 PM |
math.randomseed(os.time())
local math1 = math.random(1,10) local math2 = math.random(1,10)
print(math1 + math2)
I dunno if that's more random, but still prints a number from 1-20.
This siggy is copyrighted © |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 03:53 PM |
| Lets say I need my servers to never use the same seed so that two servers never have the same random number stream. But if the seed is tick() by default, and 2 servers are started at exactly the same time, they will have the same seed. Is this is situation where I should use random. org |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 04:03 PM |
| Or seed with something like ((tick()%1e6)*1e8)%1e7 so that the seeds would vary even when casted to an unsigned integer in the underlying C function? |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 04:05 PM |
| It's not going to be more random. That's not going to make any noticeable difference. |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2016 04:17 PM |
I need it to be random, but the next random number shouldn't be the same as the previous one.
-=[ RAP: 313,927 || DurstAuric; the narb of ROBLOX ]=- |
|
|
| Report Abuse |
|
|