mugen吧 关注:79,767贴子:1,495,264
  • 1回复贴,共1

问一个跟AI有关的问题

取消只看楼主收藏回复

技术向的问题,如有错误请指正。
这个有关摩擦计算,设击中后对方的速度是a,摩擦系数是b,我用来计算t帧后对方的距离的公式是:
p2bodydist x +abs(a)*(1-b^t)/(1-b),这个(1-b^t)/(1-b)就是等比级数求和
那么假设我要用突进技攻击对方,我所花时间就是t=(距离/vel x)
就有等式t=(p2bodydist x +abs(a)*(1-b^t)/(1-b))/vel x
那么这个t有解吗……大家有没有估算的方法……现在有一个突进技就差这一点阻力计算弄得很尴尬


1楼2013-08-05 22:10回复
    写了一个穷举法的代码,是现场算不是预先算好,没时间自己实验了,先放这明天再看orz
    一想到写代码就异常亢奋+强迫症发作orz
    伪代码:
    for(int t=0;t2<gethitvar(hittime);t1+=ifelse(t>gethitvar(slidetime),1,0), t2++){
    if(t2*vel x>p2bodydist x+abs(a)*(1-b^t1)/(1-b))
    return t2;
    }
    MUGEN代码:
    State -1里:
    [State AI]
    type = destroyself;重置
    trigger1 = ishelper
    trigger1 = ID>=16000
    trigger1 = ID<=16999
    [State AI]
    type = helper
    trigger1 = !NumHelper(11600+12);12是这个突进技的速度
    helpertype = normal
    name = "friction calculation helper"
    stateno = 11600
    ID = 11600 + 12
    pos = 0, 0
    keyctrl = 1
    pausemovetime=65535
    supermovetime=65535
    persistent = 0
    helper的state里:
    [Statedef 11600]
    anim = 6900
    ctrl = 0
    [State 11600, bindtoroot]
    type = bindtoroot
    trigger1 = 1
    time = 9999
    pos = 0, 0
    [State 11600, init]
    type = null
    trigger1 = var(0) := 0 || 1
    trigger1 = var(1) := 0 || 1
    [State 11600, enters loop]
    type = changestate
    trigger1 = 1
    value = 11601
    [Statedef 11601]
    anim = 6900
    ctrl = 0
    [State 11601, if statement];fvar(23)是对方横向速度,fvar(22)是摩擦系数
    type = changestate
    trigger1 = var(0) * (ID-11600) >= (root, p2bodydist x +abs(helper(11000),fvar(23))*(1-helper(11000),fvar(22)**(var(1)))/(1-helper(11000),fvar(22)))
    value = 11602
    [State 11601, add t]
    type = null
    trigger1 = var(0) <= enemynear,gethitvar(slidetime)
    trigger1 = var(0) := var(0) + 1 || 1
    trigger2 = var(1) := var(1) + 1 || 1
    [State 11601, end loop]
    type = changestate
    trigger1 = var(1) >= enemynear,gethitvar(hittime)
    value = 11603
    [Statedef 11602];成功
    [Statedef 11603];不成功
    判定就用helper(11600+12),stateno来判定


    6楼2013-08-06 00:17
    收起回复