zoukankan      html  css  js  c++  java
  • [手游项目2]-28-强化系统

    --概率算法
    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)
    
  • 相关阅读:
    一个网站的诞生 MagicDict开发总结8 [页面优化 能省一点是一点]
    一个网站的诞生 MagicDict开发总结6 [划词 检索]
    一个网站的诞生 MagicDict开发总结4 [如果有阶层数据库就完美了]
    一个网站的诞生 MagicDict开发总结9 [日语单词检索策略]
    一个网站的诞生 MagicDict开发总结10 [第一阶段的检索流程]
    一个网站的诞生 MagicDict 网站源码
    一个网站的诞生 MagicDict未来予想図1 [水平分割数据表的构想]
    一个网站的诞生 MagicDict开发总结3 [日语字典数据结构]
    一个网站的诞生 MagicDict开发总结5 [检索候补列表的生成]
    xcode 4 制作静态库
  • 原文地址:https://www.cnblogs.com/byfei/p/14104210.html
Copyright © 2011-2022 走看看