pseudo-random frustration

I’ve been trying to get the math.randomseed function to working for a while now and was wondering if you guys have had any better luck.Or if you knew what was wrong with my code.

[lua]
for i = 0, 10 do
math.randomseed(1337)
print(math.random(), math.random(), math.random())
end
[/lua]

This produces something like this



0.04727317117832	0.97384563737907	0.65578173162023
0.81688894314402	0.33814508499405	0.79229102450636
0.33558153019807	0.81057161168249	0.40107425153356
0.5394756920072	0.022461622974334	0.64632099368267
0.43046357615894	0.90215765861995	0.56379894405957
0.67229224524674	0.50694296090579	0.9182409131138
0.40842921231727	0.13129062776574	0.9434186834315
0.051728873561815	0.085360271004364	0.68416394543291
0.78838465529344	0.41840876491592	0.45680104983673
0.93060090945158	0.29456465346232	0.29026154362621
0.27585680715354	0.38047425763726	0.20642719809565


If I am not mistaken shouldn’t the columns be all the same number?

Nope, its called random for a reason.

Besides randomseed never really worked for me.

this article must be wrong then right?

math.randomseed() is broken in gmod.

GAH! now Ill have to write my own :frowning:

Is the “%” operator broken too?

[editline]11:32PM[/editline]

For anyone interested heres a new function you can use.

[lua]
randseed = 1337
function math.pSeedRand(fSeed)
randseed = fSeed
end
function math.pRand()
randseed = ((8253729 * randseed) + 2396403)
randseed = randseed - math.floor(randseed / 32767) * 32767
return randseed / 32767
end
[/lua]

Its not great but it works for what I need it for.