优化【杀】【南蛮入侵】【万箭齐发】【火攻】【以逸待劳】ai

This commit is contained in:
157 2024-03-17 11:56:32 +08:00
parent 964e8ea7ff
commit 8360f72c1e
4 changed files with 378 additions and 105 deletions

View File

@ -229,9 +229,9 @@ game.import('card',function(lib,game,ui,get,ai,_status){
}, },
ai:{ ai:{
basic:{ basic:{
order:4, order:9.2,
value:[3,1], value:[3,1],
useful:1, useful:0.6,
}, },
wuxie:function(target,card,player,viewer,status){ wuxie:function(target,card,player,viewer,status){
if(get.attitude(viewer,player._trueMe||player)>0) return 0; if(get.attitude(viewer,player._trueMe||player)>0) return 0;

View File

@ -1095,30 +1095,42 @@ game.import('card',function(lib,game,ui,get,ai,_status){
target.chooseToDiscard(2,'he',true).ai=get.disvalue; target.chooseToDiscard(2,'he',true).ai=get.disvalue;
}, },
ai:{ ai:{
wuxie:function(){ wuxie: function () {
return 0; return 0;
}, },
basic:{ basic: {
useful:3, order: 9,
value:3, useful: 1.5,
order:5 value: 3
}, },
result:{ result: {
target:function(player,target){ target(player, target) {
var hs=target.getCards('h'); let i,
if(hs.length<=1){ add = 0,
if(target==player&&(hs.length==0||hs[0].name=='yiyi')){ y = 1,
return 0; tars = 0;
if (!ui.selected.cards) y = 0;
if (ui.selected.targets) tars = 0.01 * ui.selected.targets.length;
else tars = 0;
if (target == player) i = player.countCards('h', function (card) {
if (y > 0 && ui.selected.cards.includes(card)) return false;
if (!y && get.name(card) === 'yiyi') {
y = -1;
return false;
} }
return 0.3; return true;
} });
return Math.sqrt(target.countCards('he')); else i = target.countCards('he');
}, if (target.hasSkillTag('noh')) add++;
return add + Math.sqrt(i / 3.6 + tars) / 2;
}
}, },
tag:{ tag: {
loseCard:1, draw: 2,
discard:1, loseCard: 2,
norepeat:1 discard: 2,
multitarget: true,
norepeat: 1
} }
}, },
}, },

View File

@ -272,17 +272,17 @@ game.import('card',function(lib,game,ui,get,ai,_status){
useful:[5,3,1], useful:[5,3,1],
value:[5,3,1], value:[5,3,1],
}, },
order:function(item,player){ order(item, player) {
if(player.hasSkillTag('presha',true,null,true)) return 10; let res = 3.2;
if(typeof item==='object'&&game.hasNature(item,'linked')){ if (player.hasSkillTag('presha', true, null, true)) res = 10;
if(game.hasPlayer(function(current){ if (typeof item !== 'object' || !game.hasNature(item, 'linked') || game.countPlayer(cur => cur.isLinked()) < 2) return res;
return current!=player&&lib.card.sha.ai.canLink(player,current,item)&&player.canUse(item,current,null,true)&&get.effect(current,item,player,player)>0; //let used = player.getCardUsable('sha') - 1.5, natures = ['thunder', 'fire', 'ice', 'kami'];
})&&game.countPlayer(function(current){ let uv = player.getUseValue(item, true);
return current.isLinked()&&get.damageEffect(current,player,player,get.nature(item))>0; if (uv <= 0) return res;
})>1) return 3.1; let temp = player.getUseValue('sha', true) - uv;
return 3; if (temp < 0) return res + 0.15;
} if (temp > 0) return res - 0.15;
return 3.05; return res;
}, },
result:{ result:{
target:function(player,target,card,isLink){ target:function(player,target,card,isLink){
@ -995,43 +995,171 @@ game.import('card',function(lib,game,ui,get,ai,_status){
} }
}, },
ai:{ ai:{
wuxie:function(target,card,player,viewer){ wuxie(target, card, player, viewer, status) {
if(get.attitude(viewer,target)>0&&target.countCards('h','sha')){ let att = get.attitude(viewer, target), eff = get.effect(target, card, player, target);
if(!target.countCards('h')||target.hp==1||Math.random()<0.7) return 0; if (Math.abs(att) < 1 || status * eff * att >= 0) return 0;
let evt = _status.event.getParent('useCard'), pri = 1, bonus = player.hasSkillTag('damageBonus', true, {
target: target,
card: card
}), damage = 1, isZhu = function (tar) {
return tar.isZhu || tar === game.boss || tar === game.trueZhu || tar === game.falseZhu;
}, canSha = function (tar, blur) {
let known = tar.getKnownCards(viewer);
if (!blur) return known.some(card => {
let name = get.name(card, tar);
return (name === 'sha' || name === 'hufu' || name === 'yuchanqian') && lib.filter.cardRespondable(card, tar);
});
if (tar.countCards('hs', i => !known.includes(i)) > 4.67 - 2 * tar.hp / tar.maxHp) return true;
if (!tar.hasSkillTag('respondSha', true, 'respond', true)) return false;
if (tar.hp <= damage) return false;
if (tar.hp <= damage + 1) return isZhu(tar);
return true;
}, self = false;
if (canSha(target)) return 0;
if (bonus && !viewer.hasSkillTag('filterDamage', null, {
player: player,
card: card
})) damage = 2;
if ((viewer.hp <= damage || viewer.hp <= damage + 1 && isZhu(viewer)) && !canSha(viewer)) {
if (viewer === target) return status;
let fv = true;
if (evt && evt.targets) for (let i of evt.targets) {
if (fv) {
if (target === i) fv = false;
continue;
}
if (viewer == i) {
if (isZhu(viewer)) return 0;
self = true;
break;
}
}
}
let maySha = canSha(target, true);
if (bonus && !target.hasSkillTag('filterDamage', null, {
player: player,
card: card
})) damage = 2;
else damage = 1;
if (isZhu(target)) {
if (eff < 0) {
if (target.hp <= damage + 1 || !maySha && target.hp <= damage + 2) return 1;
if (maySha && target.hp > damage + 2) return 0;
else if (maySha || target.hp > damage + 2) pri = 3;
else pri = 4;
}
else if (target.hp > damage + 1) pri = 2;
else return 0;
}
else if (self) return 0;
else if (eff < 0) {
if (!maySha && target.hp <= damage) pri = 5;
else if (maySha) return 0;
else if (target.hp > damage + 1) pri = 2;
else if (target.hp === damage + 1) pri = 3;
else pri = 4;
}
else if (target.hp <= damage) return 0;
let find = false;
if (evt && evt.targets) for (let i = 0; i < evt.targets.length; i++) {
if (!find) {
if (evt.targets[i] === target) find = true;
continue;
}
let att1 = get.attitude(viewer, evt.targets[i]), eff1 = get.effect(evt.targets[i], card, player, evt.targets[i]), temp = 1;
if (Math.abs(att1) < 1 || att1 * eff1 >= 0 || canSha(evt.targets[i])) continue;
maySha = canSha(evt.targets[i], true);
if (bonus && !evt.targets[i].hasSkillTag('filterDamage', null, {
player: player,
card: card
})) damage = 2;
else damage = 1;
if (isZhu(evt.targets[i])) {
if (eff1 < 0) {
if (evt.targets[i].hp <= damage + 1 || !maySha && evt.targets[i].hp <= damage + 2) return 0;
if (maySha && evt.targets[i].hp > damage + 2) continue;
if (maySha || evt.targets[i].hp > damage + 2) temp = 3;
else temp = 4;
}
else if (evt.targets[i].hp > damage + 1) temp = 2;
else continue;
}
else if (eff1 < 0) {
if (!maySha && evt.targets[i].hp <= damage) temp = 5;
else if (maySha) continue;
else if (evt.targets[i].hp > damage + 1) temp = 2;
else if (evt.targets[i].hp === damage + 1) temp = 3;
else temp = 4;
}
else if (evt.targets[i].hp > damage + 1) temp = 2;
if (temp > pri) return 0;
}
return 1;
},
basic: {
order: 9,
useful: [5, 1],
value: 5
},
result: {
player(player, target) {
if (player._nanman_temp || player.hasSkillTag('jueqing', false, target)) return 0;
player._nanman_temp = true;
let eff = get.effect(target, new lib.element.VCard({ name: 'nanman' }), player, target);
delete player._nanman_temp;
if (eff >= 0) return 0;
if (target.hp > 2 || target.hp > 1 && !target.isZhu && target != game.boss && target != game.trueZhu && target != game.falseZhu) return 0;
if (target.hp > 1 && target.hasSkillTag('respondSha', true, 'respond', true)) return 0;
let known = target.getKnownCards(player);
if (known.some(card => {
let name = get.name(card, target);
if (name === 'sha' || name === 'hufu' || name === 'yuchanqian') return lib.filter.cardRespondable(card, target);
if (name === 'wuxie') return lib.filter.cardEnabled(card, target, 'forceEnable');
})) return 0;
if (target.hp > 1 || target.countCards('hs', i => !known.includes(i)) > 4.67 - 2 * target.hp / target.maxHp) return 0;
let res = 0, att = get.sgnAttitude(player, target);
res -= att * (0.8 * target.countCards('hs') + 0.6 * target.countCards('e') + 3.6);
if (get.mode() === 'identity' && target.identity === 'fan') res += 2.4;
if (get.mode() === 'guozhan' && player.identity !== 'ye' && player.identity === target.identity ||
get.mode() === 'identity' && player.identity === 'zhu' && (target.identity === 'zhong' || target.identity === 'mingzhong')) res -= 0.8 * player.countCards('he');
return res;
},
target(player, target) {
let zhu = (get.mode() === 'identity' && target.isZhu) || target.identity === 'zhu';
if (!lib.filter.cardRespondable({ name: 'sha' }, target)) {
if (zhu) {
if (target.hp < 2) return -99;
if (target.hp === 2) return -3.6;
}
return -2;
}
let known = target.getKnownCards(player);
if (known.some(card => {
let name = get.name(card, target);
if (name === 'sha' || name === 'hufu' || name === 'yuchanqian') return lib.filter.cardRespondable(card, target);
if (name === 'wuxie') return lib.filter.cardEnabled(card, target, 'forceEnable');
})) return -1.2;
let nh = target.countCards('hs', i => !known.includes(i));
if (zhu && target.hp <= 1) {
if (nh === 0) return -99;
if (nh === 1) return -60;
if (nh === 2) return -36;
if (nh === 3) return -12;
if (nh === 4) return -8;
return -5;
}
if (target.hasSkillTag('respondSha', true, 'respond', true)) return -1.35;
if (!nh) return -2;
if (nh === 1) return -1.8;
return -1.5;
} }
}, },
basic:{ tag: {
order:9, respond: 1,
useful:[5,1], respondSha: 1,
value:5 damage: 1,
}, multitarget: 1,
result:{ multineg: 1
target_use:function(player,target){
if(player.hasUnknown(2)&&get.mode()!='guozhan') return 0;
var nh=target.countCards('h');
if(get.mode()=='identity'){
if(target.isZhu&&nh<=2&&target.hp<=1) return -100;
}
if(nh==0) return -2;
if(nh==1) return -1.7
return -1.5;
},
target:function(player,target){
var nh=target.countCards('h');
if(get.mode()=='identity'){
if(target.isZhu&&nh<=2&&target.hp<=1) return -100;
}
if(nh==0) return -2;
if(nh==1) return -1.7
return -1.5;
},
},
tag:{
respond:1,
respondSha:1,
damage:1,
multitarget:1,
multineg:1,
} }
} }
}, },
@ -1079,43 +1207,170 @@ game.import('card',function(lib,game,ui,get,ai,_status){
} }
}, },
ai:{ ai:{
wuxie:function(target,card,player,viewer){ wuxie(target, card, player, viewer, status) {
if(get.attitude(viewer,target)>0&&target.countCards('h','shan')){ let att = get.attitude(viewer, target), eff = get.effect(target, card, player, target);
if(!target.countCards('h')||target.hp==1||Math.random()<0.7) return 0; if (Math.abs(att) < 1 || status * eff * att >= 0) return 0;
let evt = _status.event.getParent('useCard'), pri = 1, bonus = player.hasSkillTag('damageBonus', true, {
target: target,
card: card
}), damage = 1, isZhu = function (tar) {
return tar.isZhu || tar === game.boss || tar === game.trueZhu || tar === game.falseZhu;
}, canShan = function (tar, blur) {
let known = tar.getKnownCards(viewer);
if (!blur) return known.some(card => {
let name = get.name(card, tar);
return (name === 'shan' || name === 'hufu') && lib.filter.cardRespondable(card, tar);
});
if (tar.countCards('hs', i => !known.includes(i)) > 3.67 - 2 * tar.hp / tar.maxHp) return true;
if (!tar.hasSkillTag('respondShan', true, 'respond', true)) return false;
if (tar.hp <= damage) return false;
if (tar.hp <= damage + 1) return isZhu(tar);
return true;
}, self = false;
if (canShan(target)) return 0;
if (bonus && !viewer.hasSkillTag('filterDamage', null, {
player: player,
card: card
})) damage = 2;
if ((viewer.hp <= damage || viewer.hp <= damage + 1 && isZhu(viewer)) && !canShan(viewer)) {
if (viewer === target) return status;
let fv = true;
if (evt && evt.targets) for (let i of evt.targets) {
if (fv) {
if (target === i) fv = false;
continue;
}
if (viewer == i) {
if (isZhu(viewer)) return 0;
self = true;
break;
}
}
}
let mayShan = canShan(target, true);
if (bonus && !target.hasSkillTag('filterDamage', null, {
player: player,
card: card
})) damage = 2;
else damage = 1;
if (isZhu(target)) {
if (eff < 0) {
if (target.hp <= damage + 1 || !mayShan && target.hp <= damage + 2) return 1;
if (mayShan && target.hp > damage + 2) return 0;
else if (mayShan || target.hp > damage + 2) pri = 3;
else pri = 4;
}
else if (target.hp > damage + 1) pri = 2;
else return 0;
}
else if (self) return 0;
else if (eff < 0) {
if (!mayShan && target.hp <= damage) pri = 5;
else if (mayShan) return 0;
else if (target.hp > damage + 1) pri = 2;
else if (target.hp === damage + 1) pri = 3;
else pri = 4;
}
else if (target.hp <= damage) return 0;
let find = false;
if (evt && evt.targets) for (let i = 0; i < evt.targets.length; i++) {
if (!find) {
if (evt.targets[i] === target) find = true;
continue;
}
let att1 = get.attitude(viewer, evt.targets[i]), eff1 = get.effect(evt.targets[i], card, player, evt.targets[i]), temp = 1;
if (Math.abs(att1) < 1 || att1 * eff1 >= 0 || canShan(evt.targets[i])) continue;
mayShan = canShan(evt.targets[i], true);
if (bonus && !evt.targets[i].hasSkillTag('filterDamage', null, {
player: player,
card: card
})) damage = 2;
else damage = 1;
if (isZhu(evt.targets[i])) {
if (eff1 < 0) {
if (evt.targets[i].hp <= damage + 1 || !mayShan && evt.targets[i].hp <= damage + 2) return 0;
if (mayShan && evt.targets[i].hp > damage + 2) continue;
if (mayShan || evt.targets[i].hp > damage + 2) temp = 3;
else temp = 4;
}
else if (evt.targets[i].hp > damage + 1) temp = 2;
else continue;
}
else if (eff1 < 0) {
if (!mayShan && evt.targets[i].hp <= damage) temp = 5;
else if (mayShan) continue;
else if (evt.targets[i].hp > damage + 1) temp = 2;
else if (evt.targets[i].hp === damage + 1) temp = 3;
else temp = 4;
}
else if (evt.targets[i].hp > damage + 1) temp = 2;
if (temp > pri) return 0;
}
return 1;
},
basic: {
order: 9,
useful: 1,
value: 5
},
result: {
player(player, target) {
if (player._wanjian_temp || player.hasSkillTag('jueqing', false, target)) return 0;
player._wanjian_temp = true;
let eff = get.effect(target, new lib.element.VCard({ name: 'wanjian' }), player, target);
delete player._wanjian_temp;
if (eff >= 0) return 0;
if (target.hp > 2 || target.hp > 1 && !target.isZhu && target != game.boss && target != game.trueZhu && target != game.falseZhu) return 0;
if (target.hp > 1 && target.hasSkillTag('respondShan', true, 'respond', true)) return 0;
let known = target.getKnownCards(player);
if (known.some(card => {
let name = get.name(card, target);
if (name === 'shan' || name === 'hufu') return lib.filter.cardRespondable(card, target);
if (name === 'wuxie') return lib.filter.cardEnabled(card, target, 'forceEnable');
})) return 0;
if (target.hp > 1 || target.countCards('hs', i => !known.includes(i)) > 3.67 - 2 * target.hp / target.maxHp) return 0;
let res = 0, att = get.sgnAttitude(player, target);
res -= att * (0.8 * target.countCards('hs') + 0.6 * target.countCards('e') + 3.6);
if (get.mode() === 'identity' && target.identity === 'fan') res += 2.4;
if (get.mode() === 'guozhan' && player.identity !== 'ye' && player.identity === target.identity ||
get.mode() === 'identity' && player.identity === 'zhu' && (target.identity === 'zhong' || target.identity === 'mingzhong')) res -= 0.8 * player.countCards('he');
return res;
},
target(player, target) {
let zhu = (get.mode() === 'identity' && target.isZhu) || target.identity === 'zhu';
if (!lib.filter.cardRespondable({ name: 'shan' }, target)) {
if (zhu) {
if (target.hp < 2) return -99;
if (target.hp === 2) return -3.6;
}
return -2;
}
let known = target.getKnownCards(player);
if (known.some(card => {
let name = get.name(card, target);
if (name === 'shan' || name === 'hufu') return lib.filter.cardRespondable(card, target);
if (name === 'wuxie') return lib.filter.cardEnabled(card, target, 'forceEnable');
})) return -1.2;
let nh = target.countCards('hs', i => !known.includes(i));
if (zhu && target.hp <= 1) {
if (nh === 0) return -99;
if (nh === 1) return -60;
if (nh === 2) return -36;
if (nh === 3) return -8;
return -5;
}
if (target.hasSkillTag('respondShan', true, 'respond', true)) return -1.35;
if (!nh) return -2;
if (nh === 1) return -1.65;
return -1.5;
} }
}, },
basic:{ tag: {
order:9, respond: 1,
useful:1, respondShan: 1,
value:5 damage: 1,
}, multitarget: 1,
result:{ multineg: 1
target_use:function(player,target){
if(player.hasUnknown(2)&&get.mode()!='guozhan') return 0;
var nh=target.countCards('h');
if(get.mode()=='identity'){
if(target.isZhu&&nh<=2&&target.hp<=1) return -100;
}
if(nh==0) return -2;
if(nh==1) return -1.7
return -1.5;
},
target:function(player,target){
var nh=target.countCards('h');
if(get.mode()=='identity'){
if(target.isZhu&&nh<=2&&target.hp<=1) return -100;
}
if(nh==0) return -2;
if(nh==1) return -1.7
return -1.5;
},
},
tag:{
respond:1,
respondShan:1,
damage:1,
multitarget:1,
multineg:1,
} }
} }
}, },

View File

@ -18318,9 +18318,16 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return get.info('ollongdan').ai.skillTagFilter(player,tag); return get.info('ollongdan').ai.skillTagFilter(player,tag);
}, },
order:function(item,player){ order:function(item,player){
if(!player||!player.storage) return; if(!player||!player.storage){
player=_status.event.player;
if(!player||!player.storage) return 0;
if(Object.keys(player.storage).some(i=>{
return typeof i=='string'&&i.indexOf('fuhan')!=-1;
})) return 4;
return 1;
}
const awakened=Object.keys(player.storage).some(i=>typeof i=='string'&&i.indexOf('fuhan')!=-1); const awakened=Object.keys(player.storage).some(i=>typeof i=='string'&&i.indexOf('fuhan')!=-1);
if(player&&_status.event.type=='phase'){ if(_status.event.type=='phase'){
var max=0; var max=0;
var list=['sha','tao','jiu']; var list=['sha','tao','jiu'];
var map={sha:'shan',tao:'jiu',jiu:'tao'} var map={sha:'shan',tao:'jiu',jiu:'tao'}
@ -18334,7 +18341,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(max>0) max+=(awakened?0.3:-0.3); if(max>0) max+=(awakened?0.3:-0.3);
return max; return max;
} }
if(!player) player=_status.event.player;
return awakened?4:1; return awakened?4:1;
}, },
}, },