重新运行时,随机数会重复。 LUA

为什么我再次运行这段代码时,随机数仍然相同:

local weightsOutput = {}
for i=0, 2 do        --初始化随机权重
     weightsOutput[i] = string.format("%0.4f",(2*math.random())-1)
     print(weightsOutput[i])
end

我的代码有什么问题吗?顺便说一下,我正在使用LUA。

点赞
用户1847592
用户1847592

开始你的程序:

math.randomseed( os.time() )
2013-04-21 15:54:55