我正在创建一台退货率约为95%的老虎机。但我觉得我经常赢得比赛。谁能证实这一点?老虎机有3个旋转器(卷轴),每个旋转器有4个不同的符号。获胜的机会应该是:
3x符号[1]:23.6%几率(第一个旋转器为50%,第二个为80%,第三个为59%)
3x符号[2]:9.45%几率(第一个旋转器为25%,第二个为70%,第三个为54%)
3x符号[3]:1.89%几率(第一个旋转器为15%,第二个为60%,第三个为21%)
3x符号[4]:0.19%几率(第一个旋转器为10%,第二个为50%,第三个为3.8%)
local symbol = {}
symbol[1] = {0.5, 0.8, 0.59}
symbol[2] = {0.5, 0.7, 0.54}
symbol[3] = {0.6, 0.6, 0.21}
symbol[4] = {1, 0.5, 0.038}
function chance(x)
if math.random() <= x then
return true
end
end
-- FIRST SPINNER
for i = 1, 4 do
if chance(symbol[i][1]) then
stop[1] = symbol[i]
break
end
end
-- SECOND SPINNER
for i = 1, 4 do
if stop[1] == symbol[i] then
if chance(symbol[i][2]) then
stop[2] = symbol[i]
else
-- stop[3] = some random symbol that is not equal to stop[1]
end
break
end
end
-- THIRD SPINNER
for i = 1, 4 do
if stop[1] == symbol[i] and stop[2] == symbol[i] then
if chance(symbol[i][3]) then
stop[3] = symbol[i]
else
-- stop[3] = some random symbol that is not equal to stop[2]
end
end
end
if stop[3] == nil then
-- stop[3] = some random symbol that is not equal to stop[2]
end
-- WIN SCRIPT
if stop[1] == stop[2] and stop[2] == stop[3] then
-- reward player
end
答案 0 :(得分:2)
local symbol = {}
symbol[1] = {0.5, 0.8, 0.59}
symbol[2] = {0.5, 0.7, 0.54}
symbol[3] = {0.6, 0.6, 0.21}
symbol[4] = {1, 0.5, 0.038}
function chance(x)
return math.random() <= x
end
-- FIRST SPINNER
for _, sym in ipairs(symbol) do
stop[1] = sym
if chance(sym[1]) then break end
end
-- SECOND SPINNER
if chance(stop[1][2]) then
stop[2] = stop[1]
-- THIRD SPINNER
if chance(stop[1][3]) then
stop[3] = stop[1]
else
-- stop[3] = some random symbol that is not equal to stop[1]
repeat
stop[3] = symbol[math.random(4)]
until stop[3] ~= stop[1]
end
else
-- stop[2], stop[3] = some random symbols, not both equal to stop[1]
repeat
stop[2] = symbol[math.random(4)]
stop[3] = symbol[math.random(4)]
until stop[2] ~= stop[1] or stop[3] ~= stop[1]
end
-- WIN SCRIPT
if stop[1] == stop[2] and stop[2] == stop[3] then
-- reward player
end