T = 1000 # times
DICE = [5, 10, 15, 20, 30] # dice
CR = [6, 7, 8, 9, 10, 11].reverse # crit
# Calc
tbl = CR.map {|cr|
DICE.map {|dice|
total = 0
T.times {
r = 0
d = dice
loop {
a = Array.new(d).map{ rand(10) + 1 }
d = a.select{|e| e >= cr }.size
if (d > 0) then
r += 10
else
r += a.max
break
end
}
total += r
}
total / T.to_f
}
}
# View
print 'C/D', DICE.map {|e| sprintf("%8d", e) }.join, "\n"
tbl.each_with_index {|e, i|
print CR[i] > 10 ? 'non' : sprintf("%3d", CR[i]), e.map {|f| sprintf("%8.2f", f) }.join, "\n"
}