More languages
More actions
m (Attempt to improve random number generator) |
m (Further improvements) |
||
Line 12: | Line 12: | ||
local s = Date:match("%d+:%d+:(%d+)") | local s = Date:match("%d+:%d+:(%d+)") | ||
local rnd = s * s * math.random(1,b) | local rnd = s * s * math.random(1,b) | ||
math.randomseed(rnd) | |||
while (rnd > b) do | while (rnd > b) do |
Revision as of 00:03, 31 October 2022
local p = {}
function p.random(frame)
local parent = frame:getParent()
local a = tonumber(parent.args[1]) or 1
local b = tonumber(parent.args[2]) or 100
local Date = os.date()
local h = Date:match("(%d+):%d+:%d+")
local m = Date:match("%d+:(%d+):%d+")
local s = Date:match("%d+:%d+:(%d+)")
local rnd = s * s * math.random(1,b)
math.randomseed(rnd)
while (rnd > b) do
rnd = math.floor(rnd/b)
end
while (rnd < a) do
rnd = math.floor(rnd*1.25)
end
return rnd
end
return p