修复新策略ai不屯桃的bug

优化【桃】【桃园结义】ai
This commit is contained in:
157 2023-10-27 22:22:32 +08:00 committed by GitHub
parent 1b76d2f8c8
commit 047db539d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 76 additions and 68 deletions

View File

@ -400,21 +400,21 @@ game.import('card',function(lib,game,ui,get,ai,_status){
}, },
ai:{ ai:{
basic:{ basic:{
order: function (card, player) { order:(card,player)=>{
if(player.hasSkillTag('pretao')) return 9; if(player.hasSkillTag('pretao')) return 9;
return 2; return 2;
}, },
useful: function (card, i) { useful:(card,i)=>{
let player = _status.event.player; let player = _status.event.player;
if(player.isDamaged()&&!game.checkMod(card,player,'unchanged','cardEnabled2',player)) return 2/(1+i); if(player.isDamaged()&&!game.checkMod(card,player,'unchanged','cardEnabled2',player)) return 2/(1+i);
let fs = game.filterPlayer(function (current) { let fs = game.filterPlayer(current=>{
return get.attitude(player,current)>0&&current.hp<=2; return get.attitude(player,current)>0&&current.hp<=2;
}), damaged = 0, needs = 0; }), damaged = 0, needs = 0;
for (let f of fs) { fs.forEach(f=>{
if (!lib.filter.cardSavable(card, player, f)) continue; if(!lib.filter.cardSavable(card,player,f)) return;
if(f.hp>1) damaged++; if(f.hp>1) damaged++;
else needs++; else needs++;
} });
if(needs&&damaged) return 5*needs+3*damaged; if(needs&&damaged) return 5*needs+3*damaged;
if(needs+damaged>1 || player.hasSkillTag('maixie')) return 8; 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(player.hp/player.maxHp<0.7) return 7+Math.abs(player.hp/player.maxHp-0.5);
@ -422,49 +422,56 @@ game.import('card',function(lib,game,ui,get,ai,_status){
if(damaged) return Math.max(3,6.4-i); if(damaged) return Math.max(3,6.4-i);
return 6.8-Math.min(5,player.hp); return 6.8-Math.min(5,player.hp);
}, },
value: function (card, player, i) { value:(card,player,i)=>{
let fs = game.filterPlayer(function (current) { let fs = game.filterPlayer(current=>{
return get.attitude(_status.event.player,current)>0; return get.attitude(_status.event.player,current)>0;
}), damaged = 0, needs = 0; }), damaged = 0, needs = 0;
for (let i of fs) { fs.forEach(f=>{
if (!player.canUse('tao', i)) continue; if(!player.canUse('tao',f)) return;
if (i.hp <= 1) needs++; if (f.hp<=1) needs++;
else if (i.hp == 2) damaged++; else if(f.hp==2) damaged++;
} });
if(needs>2) return 11; if(needs>2) return 11;
if(needs>1) return 10; if(needs>1) return 10;
if ((needs && damaged) || player.hasSkillTag('maixie')) return 9; if(needs&&damaged || player.hasSkillTag('maixie')) return 9;
if(needs || damaged>1) return 8; if(needs || damaged>1) return 8;
if(damaged) return 7.5; if(damaged) return 7.5;
return Math.max(1,9.2-player.hp); return Math.max(1,9.2-player.hp);
} }
}, },
result:{ result:{
target: function (player, target) { target:(player,target)=>{
if(target.hasSkillTag('maixie')) return 3; if(target.hasSkillTag('maixie')) return 3;
return 2; return 2;
}, },
target_use: function (player, target, card) { target_use:(player,target,card)=>{
if (player === _status.currentPhase && player.hasSkillTag('nokeep', true, {card:card,target:target}, true)) return 2; if(player===_status.currentPhase&&player.hasSkillTag('nokeep',true,{
card:card,
target:target
},true)) return 2;
let mode = get.mode(); let mode = get.mode();
if(target.hp>0){ if(target.hp>0){
let nd = player.needsToDiscard(); let nd = player.needsToDiscard();
let keep = false; let keep = 0;
if (player.isPhaseUsing()) { if(nd<2&&player.isPhaseUsing()){
if (nd <= 0 || (nd === 1 && target.hp >= 2 && player.countCards('hs', 'tao') <= 1)) keep = true; if(nd<1) keep = 3;
else if(target.hp>=2&&player.countCards('hs','tao')<=target.hp/2) keep = 1;
} }
if(keep){ if(keep){
if (!nd || nd < 2 && game.hasPlayer(function (current) { if(!nd || game.hasPlayer(current=>{
if (current.hp <= 2 && player !== current && get.attitude(player, current) > 2) { if(player!==current&&current.hp<=2&&get.attitude(player,current)>2){
if(target.hp>=2&&current.identity==='zhu'&&(mode==='identity' || mode === 'versus' || mode === 'chess')){ if(target.hp>=2&&current.identity==='zhu'&&(mode==='identity' || mode === 'versus' || mode === 'chess')){
keep=2; keep=3;
return true;
}
if(player.hp>current.hp){
keep += player.hp-current.hp;
return true; return true;
} }
if (player.hp > current.hp) return true;
} }
return false; return false;
})){ })){
if(keep>1) return 0; if(keep>2) return 0;
} }
} }
} }
@ -475,22 +482,22 @@ game.import('card',function(lib,game,ui,get,ai,_status){
} }
if(!player.getFriends().length) return 2; if(!player.getFriends().length) return 2;
let tri = _status.event.getTrigger(), let tri = _status.event.getTrigger(),
num = game.countPlayer(function (current) { num = game.countPlayer(current=>{
if(get.attitude(current,target)>0) return current.countCards('hs','tao'); if(get.attitude(current,target)>0) return current.countCards('hs','tao');
}), }),
dis = 1, dis = 1,
t = _status.currentPhase||game.me; t = _status.currentPhase||game.me;
while(t!==target){ while(t!==target){
let att = get.attitude(player,t); let att = get.attitude(player,t);
if (Math.abs(att) < 2) dis += 0.45; if(att<-2) dis++;
else if (att < 0) dis++; else if(att<1) dis += 0.45;
t = t.next; t = t.next;
} }
if(mode==='identity'){ if(mode==='identity'){
if(tri&&tri.name==='dying'){ if(tri&&tri.name==='dying'){
if(target.identity==='fan') { if(target.identity==='fan') {
if(!tri.source&&player!==target || tri.source&&tri.source!==target&&player.getFriends().includes(tri.source.identity)){ 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; if(num>dis || player===target&&player.countCards('hs',{type:'basic'})>1.6*dis) return 2;
return 0; return 0;
} }
} }
@ -499,7 +506,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
//if(player!==target&&!target.isZhu&&target.countCards('hs')<dis) return 0; //if(player!==target&&!target.isZhu&&target.countCards('hs')<dis) return 0;
} }
if(player.identity==='zhu'){ if(player.identity==='zhu'){
if (player.hp <= 1 && player !== target && player.countCards('hs', 'tao') + player.countCards('hs', 'jiu') <= Math.min(dis, game.countPlayer(function (current) { if(player.hp<=1&&player!==target&&player.countCards('hs','tao')+player.countCards('hs','jiu')<=Math.min(dis,game.countPlayer(current=>{
return current.identity==='fan'; return current.identity==='fan';
}))) return 0; }))) return 0;
} }
@ -904,8 +911,9 @@ game.import('card',function(lib,game,ui,get,ai,_status){
}, },
ai:{ ai:{
basic:{ basic:{
order:function(){ order:(item,player)=>{
return 11; if(game.hasPlayer(current=>current.hp<=1&&get.recoverEffect(current,player,_status.event.player)<0) return 1;
return 10;
}, },
useful:[3,1], useful:[3,1],
value:0, value:0,