2009-06-26, 04:28 PM (This post was last modified: 2009-06-26, 05:38 PM by Russt.)
JoeTang Wrote:It's good and all but I can't seem to find a simple way to implement it into code. Or more so, I'm lazy, so anyways.
I dunno about code to use in an application, but I too felt like killing time and wrote this (in Lua cause it's easy. sue me) for outputting your probability tables:
Spoiler
Code:
[noparse]function makeOrbTable(hitCount, tolerance, orbs)
if hitCount == 0 then return orbs end
if orbs == nil then
local newOrbs = {0.4, 0.6, 0, 0, 0, 0, 0, 0, 0, 0, 0}
return makeOrbTable(hitCount - 1, tolerance, newOrbs)
end
local newOrbs = {}
newOrbs[1] = 0.4*orbs[11]
newOrbs[2] = 0.4*orbs[1] + 0.6*orbs[11]
for i = 3, 9 do
newOrbs[i] = 0.4*orbs[i-1] + 0.6*orbs[i-2]
end
newOrbs[10] = orbs[9] + 0.6*orbs[8]
newOrbs[11] = orbs[10]
if tolerance == nil then tolerance = 0 end
for i = 1, 11 do
if math.abs(newOrbs[i] - orbs[i]) > tolerance then
return makeOrbTable(hitCount - 1, tolerance, newOrbs) -- tolerance not met
end
end
return orbs
end
function getOrbTable(mode, limit)
if mode == 'hit count' then
return makeOrbTable(limit)
elseif mode == 'tolerance' then
return makeOrbTable(-1, limit)
else
error('Invalid mode specified')
end
end
function printTable(mode, limit)
local orbs = getOrbTable(mode, limit)
for i = 1, 11 do
orbs[i] = string.format('%.4f', orbs[i])
end
io.write('[table] 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Finisher\n')
io.write(table.concat(orbs, ' | '), '[/table]\n')
end