优化【桃】ai

为nokeep标签检测加入arguments
This commit is contained in:
157 2023-10-05 17:08:30 +08:00 committed by GitHub
parent f12097ab6c
commit 0f32a0af13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 96 additions and 50 deletions

View File

@ -399,68 +399,114 @@ game.import('card',function(lib,game,ui,get,ai,_status){
target.recover(); target.recover();
}, },
ai:{ ai:{
basic:{ basic: {
order:function(card,player){ order: function (card, player) {
if(player.hasSkillTag('pretao')) return 5; if (player.hasSkillTag('pretao')) return 9;
return 2; return 2;
}, },
useful:[6.5,4,3,2], useful: function (card, i) {
value:[6.5,4,3,2], let player = _status.event.player;
if (player.isDamaged() && !game.checkMod(card, player, 'unchanged', 'cardEnabled2', player)) return 2 / (1 + i);
let fs = game.filterPlayer(function (current) {
return get.attitude(player, current) > 0 && current.hp <= 2;
}), damaged = 0, needs = 0;
for (let f of fs) {
if (!lib.filter.cardSavable(card, player, f)) continue;
if (f.hp > 1) damaged++;
else needs++;
}
if (needs && damaged) return 5 * needs + 3 * damaged;
if (needs + damaged > 1 || player.hasSkillTag('maixie')) return 8;
if (player.hp / player.maxHp < 0.7) return 7 + Math.abs(player.hp / player.maxHp - 0.5);
if (needs) return 7;
if (damaged) return Math.max(3, 6.4 - i);
return 6.8 - Math.min(5, player.hp);
}, },
result:{ value: function (card, player, i) {
target:2, let fs = game.filterPlayer(function (current) {
target_use:function(player,target){ return get.attitude(_status.event.player, current) > 0;
// if(player==target&&player.hp<=0) return 2; }), damaged = 0, needs = 0;
if(player.hasSkillTag('nokeep',true,null,true)) return 2; for (let i of fs) {
var nd=player.needsToDiscard(); if (!player.canUse('tao', i)) continue;
var keep=false; if (i.hp <= 1) needs++;
if(nd<=0){ else if (i.hp == 2) damaged++;
keep=true;
} }
else if(nd==1&&target.hp>=2&&target.countCards('h','tao')<=1){ if (needs > 2) return 11;
keep=true; if (needs > 1) return 10;
if ((needs && damaged) || player.hasSkillTag('maixie')) return 9;
if (needs || damaged > 1) return 8;
if (damaged) return 7.5;
return Math.max(1, 9.2 - player.hp);
} }
var mode=get.mode(); },
if(target.hp>=2&&keep&&target.hasFriend()){ result: {
if(target.hp>2||nd==0) return 0; target: function (player, target) {
if(target.hp==2){ if (target.hasSkillTag('maixie')) return 3;
if(game.hasPlayer(function(current){ return 2;
if(target!=current&&get.attitude(target,current)>=3){ },
if(current.hp<=1) return true; target_use: function (player, target, card) {
if((mode=='identity'||mode=='versus'||mode=='chess')&&current.identity=='zhu'&&current.hp<=2) return true; if (player === _status.currentPhase && player.hasSkillTag('nokeep', true, {card:card,target:target}, true)) return 2;
let mode = get.mode();
if (target.hp > 0) {
let nd = player.needsToDiscard();
let keep = false;
if (player.isPhaseUsing()) {
if (nd <= 0 || (nd === 1 && target.hp >= 2 && player.countCards('hs', 'tao') <= 1)) keep = true;
} }
if (keep) {
if (!nd || nd < 2 && game.hasPlayer(function (current) {
if (current.hp <= 2 && player !== current && get.attitude(player, current) > 2) {
if(target.hp >= 2 && current.identity === 'zhu' && (mode === 'identity' || mode === 'versus' || mode === 'chess')){
keep=2;
return true;
}
if (player.hp > current.hp) return true;
}
return false;
})){ })){
if(keep>1) return 0;
}
}
}
if(target.isZhu2() || target===game.boss) return 2;
if(player !== target){
if (target.hp < 0 && player.countCards('hs', 'tao') + target.hp <= 0) return 0;
if (Math.abs(get.attitude(player, target)) < 1.2) return 0;
}
if (!player.getFriends().length) return 2;
let tri = _status.event.getTrigger(),
num = game.countPlayer(function (current) {
if (get.attitude(current, target) > 0) return current.countCards('hs', 'tao');
}),
dis = 1,
t = _status.currentPhase;
while (t !== target) {
let att = get.attitude(player, t);
if (Math.abs(att) < 2) dis += 0.45;
else if (att < 0) dis++;
t = t.next;
}
if (mode === 'identity') {
if (tri && tri.name === 'dying') {
if (target.identity === 'fan') {
if (!tri.source && player !== target || tri.source && tri.source !== target && player.getFriends().includes(tri.source.identity)) {
if (num > dis || (player === target && player.countCards('hs', {type: 'basic'}) > 1.6 * dis)) return 2;
return 0; return 0;
} }
} }
else if(tri.source&&tri.source.isZhu&&(target.identity==='zhong'||target.identity==='mingzhong')&&
(tri.source.countCards('he')>2||player===tri.source&&player.hasCard((i)=>i.name!='tao','he'))) return 2;
//if(player!==target&&!target.isZhu&&target.countCards('hs')<dis) return 0;
} }
if(target.hp<0&&target!=player&&target.identity!='zhu') return 0; if (player.identity === 'zhu') {
var att=get.attitude(player,target); if (player.hp <= 1 && player !== target && player.countCards('hs', 'tao') + player.countCards('hs', 'jiu') <= Math.min(dis, game.countPlayer(function (current) {
if(att<3&&att>=0&&player!=target) return 0; return current.identity === 'fan';
var tri=_status.event.getTrigger(); }))) return 0;
if(mode=='identity'&&player.identity=='fan'&&target.identity=='fan'){
if(tri&&tri.name=='dying'&&tri.source&&tri.source.identity=='fan'&&tri.source!=target){
var num=game.countPlayer(function(current){
if(current.identity=='fan'){
return current.countCards('h','tao');
}
});
if(num>1&&player==target) return 2;
return 0;
} }
} }
if(mode=='identity'&&player.identity=='zhu'&&target.identity=='nei'){ else if (mode === 'stone' && target.isMin() && player !== target && tri && tri.name === 'dying' && player.side === target.side && tri.source !== target.getEnemy()) return 0;
if(tri&&tri.name=='dying'&&tri.source&&tri.source.identity=='zhong'){
return 0;
}
}
if(mode=='stone'&&target.isMin()&&
player!=target&&tri&&tri.name=='dying'&&player.side==target.side&&
tri.source!=target.getEnemy()){
return 0;
}
return 2; return 2;
}, }
}, },
tag:{ tag:{
recover:1, recover:1,