robomax11
|
  |
| Joined: 07 Jul 2011 |
| Total Posts: 6828 |
|
|
| 26 Sep 2014 05:03 PM |
local ids = {142295308, 142281425, 145144013, 168983825 } local music = ids[math.random(1, #ids)]
Works well in studio, but on online mode it picks the first id, why?
|
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 26 Sep 2014 05:05 PM |
Random isn't random.
Random uses some obscure formula to decide a number. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 26 Sep 2014 05:07 PM |
^ That doesn't explain why it only picks the first, though. Try this:
local ids = {142295308, 142281425, 145144013, 168983825 } math.randomseed(tick()) local music = ids[math.random(1, #ids)] |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 26 Sep 2014 05:10 PM |
Still...
Similar seeds produce similar results. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 26 Sep 2014 05:11 PM |
| And tick() will be different every time you use it. |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 26 Sep 2014 05:13 PM |
| I would think the first number would somewhat similar result within a span less than 100 or so from a somewhat distance difference of two ticks regardless. |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 26 Sep 2014 05:15 PM |
math.randomseed(math.random(math.huge))
...? |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 26 Sep 2014 05:17 PM |
I think math.huge is a negative number so that would error, actually.
And I'd think the number selected will always be the same even if you did it right from my knowledge of how random works. |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 26 Sep 2014 05:19 PM |
| It isnt random as far as I know. ( 9^9^9 ) |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
| |
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 26 Sep 2014 05:21 PM |
math.randomseed(math.random(tick(), math.huge))
|
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 26 Sep 2014 05:22 PM |
By that, I mean it IS greater than 0...
But it's read as a negative number. |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2014 05:23 PM |
I'm pretty sure a new seed is given every time a new server starts. So OP shouldn't have that problem every time he tests. |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 26 Sep 2014 05:25 PM |
for i = 1, 100 do math.randomseed(math.random(math.huge, tick())) print(math.random(1,10)) end
>
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
cmdbar so tick didnt wait |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 26 Sep 2014 05:29 PM |
@vlek That happens when you set the seed before every single iteration of the loop. |
|
|
| Report Abuse |
|
|
robomax11
|
  |
| Joined: 07 Jul 2011 |
| Total Posts: 6828 |
|
|
| 26 Sep 2014 05:58 PM |
| how would i apply this with the table? |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
| |
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 26 Sep 2014 07:46 PM |
| You can do what apple did and make a random music selector that isn't technically 100% random by making sure it doesn't choose two songs in a row. |
|
|
| Report Abuse |
|
|