AI中完全摒弃P2系代码心得

AI中使用P2系代码受敌方player型helper干扰明显 故写下个人AI中完全摒弃P2系代码的心得

技术有限 欢迎各位大神指点


【显而易见的替换】

p2statetype → enemynear,statetype

p2movetype → enemynear,movetype

p2stateno(注意,不要改动控制器参数中拉P2用的p2stateno) → enemynear,stateno

p2life → enemynear,life

p2power → enemynear,power

p2name → enemynear,name

...


【简单的替换】

p2dist x → (enemynear,pos x - pos x)*facing

p2dist y 或 p2bodydist y → enemynear,pos y - pos y


【相对复杂的替换】

p2bodydist x → fvar(25)

见以下代码(宽度检测代码第一段与最后一段有注释)


;-[分隔线]--------------------------------------------------------------------

[state -2,Deer 对方同向地面宽度检测1]

type = varset

triggerall = !ishelper

triggerall = enemynear,statetype!=A ;对手不在天上

triggerall = facing = enemynear,facing ;本体与对手朝向相同

trigger1 = facing = 1 ;都朝右

trigger1 = pos x > enemynear,pos x ;本体位置在对手右边

trigger2 = facing = -1 ;都朝左

trigger2 = pos x < enemynear,pos x ;本体位置在对手左边

v = 44

value = enemynear,const(size.ground.front)  ;返回对手地面前半身宽度值


[state -2,Deer 对方同向地面宽度检测2]

type = varset

triggerall = !ishelper

triggerall = enemynear,statetype!=A

triggerall = facing = enemynear,facing

trigger1 = facing = 1

trigger1 = pos x < enemynear,pos x

trigger2 = facing = -1

trigger2 = pos x > enemynear,pos x

v = 44

value = enemynear,const(size.ground.back)


[state -2,Deer 对方异向地面宽度检测3]

type = varset

triggerall = !ishelper

triggerall = enemynear,statetype!=A 

triggerall = facing != enemynear,facing

trigger1 = facing = 1

trigger1 = pos x < enemynear,pos x

trigger2 = facing = -1

trigger2 = pos x > enemynear,pos x

v = 44

value = enemynear,const(size.ground.front)


[state -2,Deer 对方异向地面宽度检测4]

type = varset

triggerall = !ishelper

triggerall = enemynear,statetype!=A

triggerall = facing != enemynear,facing

trigger1 = facing = 1

trigger1 = pos x > enemynear,pos x

trigger2 = facing = -1

trigger2 = pos x < enemynear,pos x

v = 44

value = enemynear,const(size.ground.back)


[state -2,Deer 对方同向空中宽度检测1]

type = varset

triggerall = !ishelper

triggerall = enemynear,statetype=A

triggerall = facing = enemynear,facing

trigger1 = facing = 1

trigger1 = pos x > enemynear,pos x

trigger2 = facing = -1

trigger2 = pos x < enemynear,pos x

v = 44

value = enemynear,const(size.air.front)


[state -2,Deer 对方同向空中宽度检测2]

type = varset

triggerall = !ishelper

triggerall = enemynear,statetype=A

triggerall = facing = enemynear,facing

trigger1 = facing = 1

trigger1 = pos x < enemynear,pos x

trigger2 = facing = -1

trigger2 = pos x > enemynear,pos x

v = 44

value = enemynear,const(size.air.back)


[state -2,Deer 对方异向空中宽度检测3]

type = varset

triggerall = !ishelper

triggerall = enemynear,statetype=A

triggerall = facing != enemynear,facing 

trigger1 = facing = 1

trigger1 = pos x < enemynear,pos x

trigger2 = facing = -1

trigger2 = pos x > enemynear,pos x

v = 44

value = enemynear,const(size.air.front)


[state -2,Deer 对方异向空中宽度检测4]

type = varset

triggerall = !ishelper

triggerall = enemynear,statetype=A  ;对手在天上

triggerall = facing != enemynear,facing ;本体与对手朝向不同

trigger1 = facing = 1 ;本体朝右 对手朝左

trigger1 = pos x > enemynear,pos x ;本体位置在对手右边

trigger2 = facing = -1 ;本体朝左 对手朝右

trigger2 = pos x < enemynear,pos x ;本体位置在对手左边

v = 44

value = enemynear,const(size.air.back) ;返回对手空中后半身宽度值

;-[分隔线]--------------------------------------------------------------------

[state -2,Deer p2bodydist x]

type = varset

triggerall = !ishelper

trigger1 = facing>0

trigger1 = (enemynear,pos x-pos x)>0

trigger2 = facing<0

trigger2 = (enemynear,pos x-pos x)<0

fv = 25

value = facing*(enemynear,pos x-pos x)-var(44)-ifelse(statetype=A,const(size.air.front),const(size.ground.front));x轴距离减去宽度条


[state -2,Deer p2bodydist x]

type = varset

triggerall = !ishelper

trigger1 = facing<0

trigger1 = (enemynear,pos x-pos x)>0

trigger2 = facing>0

trigger2 = (enemynear,pos x-pos x)<0

fv = 25

value = facing*(enemynear,pos x-pos x)+var(44)+ifelse(statetype=A,const(size.air.back),const(size.ground.back));x轴距离加上宽度条


文章首发于千寻mugen网 转载请标注来源

一只疾行蟹 评论于
白鹿Deer

@一只疾行蟹 

  承蒙蟹老板捧场  

  “如果只用enemynear,AI会无视分身的存在,然后被分身各种'偷袭'” 这点我很赞同,是我一味摒弃P2系过程中考虑欠缺的。  

  混用这个做法有待讨论。凹超杀用enemynear没有问题,连段部分用enemynear我想也没有问题。立回操作用P2写法,“一视同仁”这样的说法过于理想,真实情况是P2系代码面对player型helper时会出现P2状态判断混乱,从而AI会表现失常,基于P2系的立回在这样的条件下的有效性难以保证。当然在对手有分身的情况下,“有混乱”应当是比“完全不考虑”要好的。但对手有player型helper并不等价于对手有分身,而面对这些人物时用p2系倒不如enemynear了。明面上靠分身打架的人物不多,但很难说清有多少人物藏着player型helper。 

@白鹿(Deer) 那就有点哈人了,,,
你这么一说才想起来,大概2年前看过个塞克尔,
放技能会让对手的AI一直朝着另一面,理论上要实现这个,应该就是player型helper了,确实够肮脏的,,,

白鹿Deer 评论于
一只疾行蟹

吓我一跳,还以为是直接无视对手写AI,“还能这样写?!”心里这样想着点进来了(

其实p2和enemynear两种写法最好还是混用
虽然两种写法对于打纯本体的对手都没区别,但是如果对手有"分身"之类的设定,就会表现出不同了
enemynear是识别不到helpertype=player的helper的,p2写法则会识别到
helpertype=player的helper,就以12P的EV妮子举例吧
如果只用enemynear,AI会无视分身的存在,然后被分身各种"偷袭"
如果只用p2写法,会导致AI一直对着能无限复活的分身凹即死
混用的话,简单举个例子,
比如说裸凹即死的changestate,就用enemynear,确保是对着本体使的
而正常的立回操作则用p2写法,确保不管是本体还是分身都能一视同仁

@一只疾行蟹 

  承蒙蟹老板捧场  

  “如果只用enemynear,AI会无视分身的存在,然后被分身各种'偷袭'” 这点我很赞同,是我一味摒弃P2系过程中考虑欠缺的。  

  混用这个做法有待讨论。凹超杀用enemynear没有问题,连段部分用enemynear我想也没有问题。立回操作用P2写法,“一视同仁”这样的说法过于理想,真实情况是P2系代码面对player型helper时会出现P2状态判断混乱,从而AI会表现失常,基于P2系的立回在这样的条件下的有效性难以保证。当然在对手有分身的情况下,“有混乱”应当是比“完全不考虑”要好的。但对手有player型helper并不等价于对手有分身,而面对这些人物时用p2系倒不如enemynear了。明面上靠分身打架的人物不多,但很难说清有多少人物藏着player型helper。 

一只疾行蟹 评论于

吓我一跳,还以为是直接无视对手写AI,“还能这样写?!”心里这样想着点进来了(

其实p2和enemynear两种写法最好还是混用
虽然两种写法对于打纯本体的对手都没区别,但是如果对手有"分身"之类的设定,就会表现出不同了
enemynear是识别不到helpertype=player的helper的,p2写法则会识别到
helpertype=player的helper,就以12P的EV妮子举例吧
如果只用enemynear,AI会无视分身的存在,然后被分身各种"偷袭"
如果只用p2写法,会导致AI一直对着能无限复活的分身凹即死
混用的话,简单举个例子,
比如说裸凹即死的changestate,就用enemynear,确保是对着本体使的
而正常的立回操作则用p2写法,确保不管是本体还是分身都能一视同仁

根据相关规定,发布评论前必须绑定手机前往绑定
你,确定要这么做吗?
正在处理中...