Module:Random: Difference between revisions

Content deleted Content added
add function to get random dates; and add support for random numbers over 2^32-1 (using an algorithm supplied by User:Anomie)
attempt at getting better randomness
Line 5:
local makeList = require('Module:List').makeList
 
-- Set the seed for the random number togenerator. theThis currentworks numberwell ofon editsthe madeEnglish Wikipedia due to Wikipedia.the high
-- edit rate, but should also work well on smaller wikis due to the variability of os.time() (the current time)
-- The English Wikipedia gets dozens of edits each minute, so this is as close to a random seed
-- and os.clock() (the time the program takes to run).
-- as we have. On smaller wikis this will produce the same number if the edit count has not changed,
math.randomseed(mw.site.stats.edits + mw.site.stats.pages + os.time() + math.floor(os.clock() * 1000000000))
-- so please use it with caution.
 
math.randomseed(mw.site.stats.edits)
-- Call math.random a few times to avoid getting the same first answer every time.
math.random()
math.random()
math.random()
 
--------------------------------------------------------------------------------------