Last edit: @jheafpp in #[IM @jheafpp] 4 months ago - Slack Archive

{lua}
local A1, A2 = 727595, 798405  -- 5^17=D20*A1+A2
local D20, D40 = 1048576, 1099511627776  -- 2^20, 2^40
local X1, X2 = math.random(0, 1048575), math.random(0, 1048575)
function rand()
    local U = X2*A2
    local V = (X1*A2 + X2*A1) % D20
    V = (V*D20 + U) % D40
    X1 = math.floor(V/D20)
    X2 = V - X1*D20
    return V/D40
end
i = 0
dice = tonumber(argv[1])
sides = tonumber(argv[2])
while i < dice and dice ~= nil and sides ~= nil do
    print(math.ceil((rand() * sides)))
    print("\n")
    i = i + 1
end

History

Revision: 4790 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
local A1, A2 = 727595, 798405  -- 5^17=D20*A1+A2
local D20, D40 = 1048576, 1099511627776  -- 2^20, 2^40
local X1, X2 = math.random(0, 1048575), math.random(0, 1048575)
function rand()
    local U = X2*A2
    local V = (X1*A2 + X2*A1) % D20
    V = (V*D20 + U) % D40
    X1 = math.floor(V/D20)
    X2 = V - X1*D20
    return V/D40
end
i = 0
dice = tonumber(argv[1])
sides = tonumber(argv[2])
while i < dice and dice ~= nil and sides ~= nil do
    print(math.ceil((rand() * sides)))
    print("\n")
    i = i + 1
end

Revision: 4787 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
local A1, A2 = 727595, 798405  -- 5^17=D20*A1+A2
local D20, D40 = 1048576, 1099511627776  -- 2^20, 2^40
local X1, X2 = math.random(0, 1048575), math.random(0, 1048575)
function rand()
    local U = X2*A2
    local V = (X1*A2 + X2*A1) % D20
    V = (V*D20 + U) % D40
    X1 = math.floor(V/D20)
    X2 = V - X1*D20
    return V/D40
end
i = 0
dice = tonumber(argv[1])
sides = tonumber(argv[2])
while i < dice and dice ~= nil and sides ~= nil do
    print(math.ceil((rand() * sides)))
    i = i + 1
end

Revision: 4785 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
local A1, A2 = 727595, 798405  -- 5^17=D20*A1+A2
local D20, D40 = 1048576, 1099511627776  -- 2^20, 2^40
local X1, X2 = math.random(0, 1048575), math.random(0, 1048575)
function rand()
    local U = X2*A2
    local V = (X1*A2 + X2*A1) % D20
    V = (V*D20 + U) % D40
    X1 = math.floor(V/D20)
    X2 = V - X1*D20
    return V/D40
end
i = 0
dice = tonumber(argv[1])
sides = tonumber(argv[2])
while i < dice and dice ~= nil and sides ~= nil do
    print(math.floor((rand() * sides)))
    i = i + 1
end

Revision: 4783 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
local A1, A2 = 727595, 798405  -- 5^17=D20*A1+A2
local D20, D40 = 1048576, 1099511627776  -- 2^20, 2^40
local X1, X2 = 0, 1048575
function rand()
    local U = X2*A2
    local V = (X1*A2 + X2*A1) % D20
    V = (V*D20 + U) % D40
    X1 = math.floor(V/D20)
    X2 = V - X1*D20
    return V/D40
end
i = 0
dice = tonumber(argv[1])
sides = tonumber(argv[2])
while i < dice and dice ~= nil and sides ~= nil do
    print(math.floor((rand() * sides)))
    i = i + 1
end

Revision: 4776 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
i = 0
dice = tonumber(argv[1])
sides = tonumber(argv[2])
while i < dice and dice ~= nil and sides ~= nil do
    print(math.random(sides))
    i = i + 1
end

Revision: 4774 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
i = 0
dice = tonumber(argv[1])
sides = tonumber(argv[2])
while i < dice and dice ~= nil and sides ~= nil do
    print(math.random(sides))
    i++
end

Revision: 4773 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
i = 0
dice = tonumber(argv[1])
sides = tonumber(argv[2])
while i < dice and dice ~= nil and sides ~= nil do
    print(math.random(sides))
end

Revision: 4772 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
i = 0
dice = tonumber(argv[1])
sides = tonumber(argv[2])
while i < dice and dice ~= nil and sides ~= nil do
    print(math.random(sides))

Revision: 4771 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

&!

Revision: 4763 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}

math.randomseed(os.time())
print(math.random(6))

Revision: 4761 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}

local function ToInteger(number)
    return math.floor(tonumber(number) or error("Could not cast '" .. tostring(number) .. "' to number.'"))
end
math.randomseed(os.time())
print(ToInteger(math.random(6)))

Revision: 4759 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
local A1, A2 = 727595, 798405  
local D20, D40 = 1048576, 1099511627776 
local X1, X2 = 0, 1
function rand()
  local U = X2*A2
  local V = (X1*A2 + X2*A1) % D20
  V = (V*D20 + U) % D40
  X1 = math.floor(V/D20)
  X2 = V - X1*D20
  return V/D40
end
local function ToInteger(number)
    return math.floor(tonumber(number) or error("Could not cast '" .. tostring(number) .. "' to number.'"))
end

print(ToInteger(rand()*6))

Revision: 4740 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

local A1, A2 = 727595, 798405  
local D20, D40 = 1048576, 1099511627776 
local X1, X2 = 0, 1
function rand()
   local U = X2*A2
   local V = (X1*A2 + X2*A1) % D20
   V = (V*D20 + U) % D40
   X1 = math.floor(V/D20)
   X2 = V - X1*D20
   return V/D40
end

print(tonumber(rand()*6))

Revision: 4738 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

local A1, A2 = 727595, 798405  -- 5^17=D20*A1+A2
local D20, D40 = 1048576, 1099511627776  -- 2^20, 2^40
local X1, X2 = 0, 1
function rand()
   local U = X2*A2
   local V = (X1*A2 + X2*A1) % D20
   V = (V*D20 + U) % D40
   X1 = math.floor(V/D20)
   X2 = V - X1*D20
   return V/D40
end

print(tonumber(rand()*6))

Revision: 4723 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

local A1, A2 = 727595, 798405  -- 5^17=D20*A1+A2
local D20, D40 = 1048576, 1099511627776  -- 2^20, 2^40
local X1, X2 = 0, 1
function rand()
    local U = X2*A2
    local V = (X1*A2 + X2*A1) % D20
    V = (V*D20 + U) % D40
    X1 = math.floor(V/D20)
    X2 = V - X1*D20
    return V/D40
end

print(math.rand()*6)

Revision: 4722 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

local A1, A2 = 727595, 798405  -- 5^17=D20*A1+A2
local D20, D40 = 1048576, 1099511627776  -- 2^20, 2^40
local X1, X2 = 0, 1
function rand()
    local U = X2*A2
    local V = (X1*A2 + X2*A1) % D20
    V = (V*D20 + U) % D40
    X1 = math.floor(V/D20)
    X2 = V - X1*D20
    return V/D40
end

Revision: 4721 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
math.randomseed(os.time())
print(math.random(6))

Revision: 4720 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
print(math.random(6))

Revision: 4719 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

print(math.random(6))

Revision: 4718 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

{lua}
for i = 1 
do print(math.random(6))
end

Revision: 4717 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

&2