Random 再次运行LUA时重复随机数
当我再次运行此代码时,为什么会从上一次运行中获得相同的随机数:Random 再次运行LUA时重复随机数,random,lua,Random,Lua,当我再次运行此代码时,为什么会从上一次运行中获得相同的随机数: local weightsOutput = {} for i=0, 2 do --initialize random weights weightsOutput[i] = string.format("%0.4f",(2*math.random())-1) print(weightsOutput[i]) end 我的代码有问题吗?顺便说一下,我正在使用LUA。用 math.randomseed(
local weightsOutput = {}
for i=0, 2 do --initialize random weights
weightsOutput[i] = string.format("%0.4f",(2*math.random())-1)
print(weightsOutput[i])
end
我的代码有问题吗?顺便说一下,我正在使用LUA。用
math.randomseed( os.time() )