۲۱٬۴۶۶
ویرایش
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
خط ۵۳: | خط ۵۳: | ||
-- Source: https://stackoverflow.com/questions/35572435/how-do-you-do-the-fisher-yates-shuffle-in-lua | -- Source: https://stackoverflow.com/questions/35572435/how-do-you-do-the-fisher-yates-shuffle-in-lua | ||
function FYShuffle(tInput | function FYShuffle(tInput) | ||
math.randomseed(os.time()) | |||
local tReturn = {} | local tReturn = {} | ||
for i = #tInput, 1, -1 do | for i = #tInput, 1, -1 do | ||
local j = | local j = math.random(i) | ||
tInput[i], tInput[j] = tInput[j], tInput[i] | |||
table.insert(tReturn, | table.insert(tReturn, tInput[i]) | ||
end | end | ||
return tReturn | return tReturn |