--概率算法
local randlist = {85,60,55,50,50,40,35,25,20,15,12,10,10,5,5} --概率
local countlist = {0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0} --统计强化次数
local randlist2 = {} --正常概率
local randlist3 = {} --+15%概率
local randlib = 100
local target = 8
local maxfor = 100000
math.randomseed(os.time())
--初始化正常概率
for k,v in pairs(randlist)do
local numList = {}
local count = 0
for i=1,randlib do
if(count < v )then
count = count + 1
table.insert(numList,1)
else
table.insert(numList,0)
end
end
--洗牌交换
for i=1,randlib do
local nRand = math.random(1,100)
local a = numList[i]
numList[i] = numList[nRand]
numList[nRand] = a
end
local strList = ""
for i,j in pairs(numList)do
strList = strList..tostring(j)
end
--print("强化"..tostring(k))
--print(strList)
table.insert(randlist2,numList)
end
--初始化+15概率
for k,v in pairs(randlist)do
local numList = {}
local count = 0
for i=1,randlib do
if(count < v+15)then
count = count + 1
table.insert(numList,1)
else
table.insert(numList,0)
end
end
--洗牌交换
for i,j in pairs(numList)do
local nRand = math.random(1,randlib)
local a = numList[i]
numList[i] = numList[nRand]
numList[nRand] = a
end
local strList = ""
for i,j in pairs(numList)do
strList = strList..tostring(j)
end
--print("强化"..tostring(k))
--print(strList)
table.insert(randlist3,numList)
end
--完毕
local strengh = 0
local money = 0
local strmoney = ""
for i=1, maxfor do
money = money + 1
local index = strengh + 1
local index2 = countlist[index]
if(randlist2[index][index2] == 1)then
strengh = strengh +1
else
strengh = strengh - 1
if(strengh < 1)then
strengh = 1
end
end
countlist[index] = countlist[index] + 1
if(randlib < countlist[index])then
countlist[index] = 1
end
--strmoney = strmoney..tostring(strengh)
if(target<=strengh)then
break
end
end
--print(strmoney)
print(money)
--吉星
money = 0
strengh = 0
strmoney = ""
for i=1, maxfor do
money = money + 1
local index = strengh + 1
local index2 = countlist[index]
if(randlist3[index][index2] == 1)then
strengh = strengh +1
else
strengh = 1
if(strengh < 1)then
strengh = 1
end
end
countlist[index] = countlist[index] + 1
if(randlib < countlist[index])then
countlist[index] = 1
end
--strmoney = strmoney..tostring(strengh)
if(target<=strengh)then
break
end
end
--print(strmoney)
print(money)
--强化属性
local attrlist = {87,204,380,585,828,1101,1411,1753,2128,2531,2965,3429,4023,4648,5406,6194,7018,7775,8609,9526}
--result = {1.0 2.3 4.4 6.7 9.5 12.7 16.2 20.1 24.5 29.1 34.1 39.4 46.2 53.4 62.1 71.2 80.7 89.4 99.0 109.5}
local strprint = ""
local first = attrlist[1]
for k,v in pairs(attrlist)do
--local value = math.modf(v / first)
local value = string.format("%.1f",v/first)
strprint = strprint..tostring(value).." "
end
print(strprint)