Lua中的随机

math.random and math.randomseed

math.randomseed(os.time())
for i=1,10000000 do
	print(math.random(1,100))
end

这样随机出来的数,随机性很小,即使os.time()的值在变化,但是影响不大

解决方法: 倒序os.time() 然后取前六位,作为randomseed

local randomseed = tonumber(tostring(os.time()):reverse():sub(1,6))
math.randomseed(randomseed)
local randomValue = math.random(m, n)