诺亚幻想抽卡——玩家控制概率的抽卡系统

玩家控制概率?

和传统的抽卡方式消耗单一资源(钻石,金币,十连抽礼券)不同,《诺亚幻想》的抽卡,是需要消耗多种资源,每一种资源玩家都可以配置相应的数值,相当于在真正的抽卡逻辑之前,进行了策划的配置权重的工作,相应的,配置好数值之后,对于所有英雄抽卡获得的概率都会改变。这种抽卡被玩家称之为诺亚幻想大建,每个英雄对应的最佳的各种资源的数值被称之为大建公式,从最终的抽卡体验来看,很多玩家都觉得这是谜一样的抽卡。到底内部逻辑是怎样的呢?
先来看一张大建的图:
在这里插入图片描述

金黑翠苍赤五种曜石,在大建时每一种曜石的数量最少设置50,最高999。那么一共有950的5次方,也就是773780937500000种大建公式。为每一个公式都准备一个抽取的库显然是不可能的。实际上,总共只有20个库,由5种曜石和4种cost(学员分为cost5,6,7,9这4种)组合而成。玩家准备的公式,决定了分库随机中,20个库分别可以随机到的概率。如果理解了随机的概率算法,玩家就可以通过配置建造公式,真正增加随出某个库(比如cost9水(苍)属性库)的概率。那么这20个概率是怎样确定的呢?

库概率计算

首先,我们来理解一个概念,叫做权重函数,用于计算最终的特定库的权重。设x1,x2,x3,x4,x5分别对应五种曜石数量,S为输入的曜石总数。
总权重函数为:
W i , k = H i C k (i对应5种曜石, k对应4种cost) \tag*{(i对应5种曜石, k对应4种cost)} W_{i,k} = H_iC_k Wi,k=HiCk(i对应5种曜石, k对应4cost)
曜石权重函数:
H i = x i 3 x 1 3 + x 2 3 + x 3 3 + x 4 3 + x 5 3 x为曜石数量 \tag*{x为曜石数量} H_i = \cfrac{x_i^3}{x_1^3 + x_2^3 + x_3^3 + x_4^3 + x_5^3} Hi=x13+x23+x33+x43+x53xi3x为曜石数量
曜石总数权重函数:
C k = a k e x p − ( S − b k ) 2 2 c k 2 , S = x 1 + x 2 + x 3 + x 4 + x 5 a,b,c为常数 \tag*{a,b,c为常数} C_k = a_kexp^\cfrac{-(S - b_k)^2}{2c_k^2}, S = x_1 + x_2 + x_3 + x_4 + x_5 Ck=akexp2ck2(Sbk)2S=x1+x2+x3+x4+x5a,b,c为常数
由上述公式,我们可以得出以下结论:

  1. 总权重由曜石权重函数和总数权重函数共同决定,要想最大程度提高特定库的概率,我们需要同时提高两个权重函数的值。
  2. 对于曜石权重函数来说,特定的曜石数量越多,其它种类曜石数量越少,并且其它曜石数量越平均,那么随机到这种曜石对应的库的几率越大。举例说明:如果想提高水属性学员概率,那么水曜石尽可能的放多,其它的尽可能放少。
  3. 对于曜石总数权重函数,我们放入的曜石总数越接近b的值,那么对应的cost的库权重越大。因为这是一个正态分布函数。两边同时求对数可以得到:
    ln ⁡ C k = ln ⁡ a k − ( S − b k ) 2 2 c k 2 \ln C_k = \ln a_k - \cfrac{(S - b_k)^2}{2c_k^2} lnCk=lnak2ck2(Sbk)2
    如果S的值与b相等,那么最终权重为a。
  4. 总结来说,想要最大化某个库的概率,需要 其对应种类的曜石数量越多,总曜石越近b的值。

那么b的值是多少呢?

costbac
cost5学员库2501.51229.2
cost6学员库245011350
cost7学员库39001.11520
cost9学员库440011063.3

那么问题来了,两个权重函数可能相互冲突,你能取最大值,我就不能,怎样确定最终的最大概率的数值呢?
由于关键的曜石数量需要最大,其它曜石可以算作平均值处理,并把曜石总数也作为一个变量y,所以权重函数做如下变化。
W x , y = a x 3 x 3 + 4 ( y − x 4 ) 3 e x p − ( y − b ) 2 2 c 2 y为总曜石数量 \tag*{y为总曜石数量} W_{x,y} = a\cfrac{x^3}{x^3 + 4(\cfrac{y - x}{4})^3}exp^\cfrac{-(y - b)^2}{2c^2} Wx,y=ax3+4(4yx)3x3exp2c2(yb)2y为总曜石数量
这就演变为一个求二元函数极大值问题。并且限定为:
x ∈ [ 50 , 999 ) , y ⩾ x + 200 , y ⩽ 5 x x \in [50,999) , y\geqslant x + 200, y \leqslant 5x x[50,999),yx+200,y5x
有数学大佬可以帮忙算一下吗?
咱们还是写程序算出来最大概率的公式吧。

local config = {
    -- 学员单一库配置
    static_drop_libs = {
      light = {
        [5] = 200001,
        [6] = 200002,
        [7] = 200003,
        [9] = 200004
      },
      dark = {
        [5] = 200005,
        [6] = 200006,
        [7] = 200007,
        [9] = 200008
      },
      wind = {
        [5] = 200009,
        [6] = 200010,
        [7] = 200011,
        [9] = 200012
      },
      water = {
        [5] = 200013,
        [6] = 200014,
        [7] = 200015,
        [9] = 200016
      },
      fire = {
        [5] = 200017,
        [6] = 200018,
        [7] = 200019,
        [9] = 200020
      }
    },
    -- 学员 Cost 的正态函数参数
    cost_normal_functions = {
      [5] = {
        a = 1.5,
        b = 250,
        c = 1229.2
      },
      [6] = {
        a = 1,
        b = 2450,
        c = 1350
      },
      [7] = {
        a = 1.1,
        b = 3900,
        c = 1520
      },
      [9] = {
        a = 1,
        b = 4400,
        c = 1063.3
      }
    }
}

local ELEM_FIELDS =  {
    [1] = "light",
    [2] = "dark",
    [3] = "wind",
    [4] = "water",
    [5] = "fire"
}

local function get_formulaes(req)
    local elem_weights = {}
    local elem_target = 0
    local elem_sumcubic = 0
    for elem_id, elem_field in pairs(ELEM_FIELDS) do
        local v = req[elem_field]
        local cubic = v * v * v
        elem_weights[elem_id] = cubic
        elem_sumcubic = elem_sumcubic + cubic
        elem_target = elem_target + v
    end
    for k, v in pairs(elem_weights) do
        elem_weights[k] = v / elem_sumcubic -- 权重为 各自的立方 除以 立方和
    end

    local cost_weight_sum = 0
    local cost_weights = {}
    for c, n in pairs(config.cost_normal_functions) do
        local distance = elem_target - n.b
        local cw = n.a * math.exp(- distance * distance / 2 / n.c / n.c)
        cost_weights[c] = cw
        cost_weight_sum = cost_weight_sum + cw
    end
    for k, v in pairs(cost_weights) do
        cost_weights[k] = v / cost_weight_sum
    end

    local formulaes = {}
    for elem_id, elem_name in pairs(ELEM_FIELDS) do
        local ew = elem_weights[elem_id]
        local elem_drop_libs = assert(config.static_drop_libs[elem_name])
        for c, cw in pairs(cost_weights) do
            local drop_id = elem_drop_libs[c]
            if drop_id then
                local weight = ew * cw
                table.insert(formulaes, {
                    dropId = drop_id,
                    weight = weight
                })
            end
        end
    end
    return formulaes
end

local function check_prob(drop_target, current, other)
    local result = get_formulaes({light=other, dark = other, wind = other, water = current, fire = other})
    -- local drop_target = 200013
    local target_weight = 0
    local sum = 0
    for _, drop in pairs(result) do
        if drop.dropId == drop_target then
            target_weight = drop.weight
        end
        sum = sum + drop.weight
    end
    if target_weight ~= 0 then
        local prob = target_weight / sum
        -- print(prob)
        return prob
    end
    return 0
end

local bbb = {
    [5] = 250,
    [6] = 2450,
    [7] = 3900,
    [9] = 4400
}

local from = 50
local to = 999
local interval = 1
local max = 0
local bingo = nil
local bingoOther = nil
for index, target in pairs(config.static_drop_libs.water) do
    local total = bbb[index]
    for i = from,to,interval do
        local totalMin = total * 0.8
        local totalMax = total * 1.2
        if totalMin < 250 then
            totalMin = 250
        end
        if totalMax > 4996 then
            totalMax = 4996
        end
        for j = totalMin,totalMax,interval do
            local other = math.floor((j - i)/4)
            if other < 50 then
                other = 50
            elseif other > 999 then
                other = 999
            end
            local result = check_prob(target, i, other)
            if result > max then
                max = result
                bingo = i
                bingoOther = other
            end
        end
    end
    print(index,"bingo:",bingo,"prob:",max,"other:",bingoOther)
    bingo = nil
    max = 0
    bingoOther = nil
end

运行结果:

9       bingo:  999     prob:   0.13988862461048        other:  666
5       bingo:  265     prob:   0.75589757110106        other:  50
6       bingo:  999     prob:   0.42954544628168        other:  246
7       bingo:  999     prob:   0.24826871710409        other:  530

可以得出以下结论:
cost9水属性库,大建公式为, 水曜石999,其它曜石666,概率为13.98%
cost7水属性库,大建公式为, 水曜石999,其它曜石530,概率为24.83%
cost6水属性库,大建公式为, 水曜石999,其它曜石246,概率为42.95%
cost5水属性库,大建公式为, 水曜石265,其它曜石50,概率为75.6%,。

总结

cost越高的学员,越难抽取。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值