改进两个猜测牌的AI
This commit is contained in:
parent
7e00653436
commit
f470146b8c
|
@ -2538,6 +2538,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
targets[event.num].chooseBool("是否押杀?").ai=function(event,player){
|
||||
var evt=_status.event.getParent();
|
||||
if(get.attitude(targets[event.num],evt.player)>0) return evt.player.countCards('h','sha')?false:true;
|
||||
if(evt.player.hasKnownCards(targets[event.num],c=>{return c.name == 'sha';})){
|
||||
return true;
|
||||
}
|
||||
return Math.random()<0.5;
|
||||
};
|
||||
"step 2"
|
||||
|
|
|
@ -466,8 +466,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
return _status.event.choice;
|
||||
}).set('choice',function(){
|
||||
var num=trigger.player.countCards('h',card=>get.type2(card)==type);
|
||||
var knownNum = trigger.player.countKnownCards(_status.event.player,card=>get.type2(card)==type);
|
||||
if(trigger.player.isAllCardsKnown(_status.event.player)){
|
||||
return knownNum;
|
||||
}
|
||||
var restNum = num - knownNum;
|
||||
var numx;
|
||||
if(type=='basic') numx=num+(Math.random()<0.2?(Math.random()>0.5?1:-1):0);
|
||||
if(type=='basic') numx=num+Math.floor(Math.random()*restNum+1);
|
||||
else if(type=='trick'){
|
||||
if(num>2) numx=2;
|
||||
else numx=1;
|
||||
|
@ -478,7 +483,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
|
|||
else{
|
||||
numx=[0,1].randomGet();
|
||||
}
|
||||
if(numx<0) numx=0;
|
||||
if(numx<knownNum) numx=knownNum;
|
||||
else if(numx>=choices.length) numx=choices.length-1;
|
||||
return numx;
|
||||
}());
|
||||
|
|
26
game/game.js
26
game/game.js
|
@ -19317,9 +19317,15 @@
|
|||
for(var num=0;num<cards.length;num++){
|
||||
sort=lib.config.sort_card(cards[num]);
|
||||
if(lib.config.reverse_sort) sort=-sort;
|
||||
if(['o','d'].contains(get.position(cards[num],true))){
|
||||
cards[num].addKnower('everyone');
|
||||
}
|
||||
cards[num].fix();
|
||||
cards[num].style.transform='';
|
||||
cards[num].addGaintag(event.gaintag);
|
||||
if(event.knowers){
|
||||
cards[num].addKnower(event.knowers);//添加事件设定的知情者。
|
||||
}
|
||||
if(_status.discarded){
|
||||
_status.discarded.remove(cards[num]);
|
||||
}
|
||||
|
@ -21016,6 +21022,10 @@
|
|||
return card.isKnownBy(other) && filter(card);
|
||||
}) > 0;
|
||||
}
|
||||
//数此角色被知道的牌。
|
||||
countKnownCards(other,filter){
|
||||
return this.getKnownCards(other,filter).length;
|
||||
}
|
||||
//Execute the delay card effect
|
||||
//执行延时锦囊牌效果
|
||||
executeDelayCardEffect(card,target,judge,judge2){
|
||||
|
@ -30591,6 +30601,21 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
removeKnower(player){
|
||||
if(!this._knowers){
|
||||
return;
|
||||
}
|
||||
if(typeof player == 'string'){
|
||||
this._knowers.remove(player);
|
||||
}else{
|
||||
let type = get.itemtype(player);
|
||||
if(type == 'player'){
|
||||
this._knowers.remove(player.playerid);
|
||||
}else if(type == 'players'){
|
||||
player.forEach(p=>this._knowers.remove(p.playerid));
|
||||
}
|
||||
}
|
||||
}
|
||||
//清除此牌的知情者。
|
||||
clearKnowers(){
|
||||
if(this._knowers)delete this._knowers;
|
||||
|
@ -35843,6 +35868,7 @@
|
|||
for(let i=0;i<ui.discardPile.childNodes.length;i++){
|
||||
var currentcard=ui.discardPile.childNodes[i];
|
||||
currentcard.vanishtag.length=0;
|
||||
currentcard.clearKnowers();
|
||||
if(get.info(currentcard).vanish||currentcard.storage.vanish){
|
||||
currentcard.remove();
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue