diff --git a/dist/css/app.d8f0477c.css b/dist/css/app.d8f0477c.css deleted file mode 100644 index 260923a9261bb3a5e20d5ce8706f92c90f4eb637..0000000000000000000000000000000000000000 --- a/dist/css/app.d8f0477c.css +++ /dev/null @@ -1 +0,0 @@ -.poker[data-v-4dff4871],.pokerDesk[data-v-4dff4871]{height:100%;width:100px;border:1px solid;border-radius:16px;float:left;margin-left:-50px;background-color:azure;font-size:30px}.poker[data-v-4dff4871]:hover{background-color:#faebd7}.selected[data-v-4dff4871]{margin-top:-20px} \ No newline at end of file diff --git a/dist/index.html b/dist/index.html index c2a508d3e2ab4c8a1539df954e04d1147b72f58a..42f47cd914daf6d386314284d740c7337571b2d4 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1 +1 @@ -Vue App
\ No newline at end of file +Vue App
\ No newline at end of file diff --git a/src/components/Game.vue b/src/components/Game.vue index c4593e36a832c82e7e56eef2be5c3342cbbde64a..cf9b463898185b8df11420956157e202ad348f43 100644 --- a/src/components/Game.vue +++ b/src/components/Game.vue @@ -178,6 +178,7 @@ export default { }, mounted() { this.data = this.game.playerList[1].name; + window.game = this.game; }, methods:{ enter: function(e, poker){ diff --git a/src/doudizhu/AI.js b/src/doudizhu/AI.js index d0454859dabe4ac1abf80d17621ba66b755f576f..6bd10ba0bc423cfec430d4a04e68be3423a40ff7 100644 --- a/src/doudizhu/AI.js +++ b/src/doudizhu/AI.js @@ -321,13 +321,8 @@ class AI{ //接牌3 最小接 不拆 不炸 不出王、2、AAA getByObj3(lastObj){ let obj; - obj = this.getSmallestObjByObj(lastObj); - - if(obj){ - if(lastObj){ + obj = this.getSmallestObjNoBig(lastObj); - } - } return obj; } @@ -395,7 +390,7 @@ class AI{ //接牌5 getByObj5(lastObj){ - let obj = this.getByBoom(); + let obj = this.getByBoom(lastObj); if(!obj){ if(this.player.pokerList[this.player.pokerList.length-1].number>lastObj.one[0].number){ @@ -411,6 +406,20 @@ class AI{ } + //接牌6 + getByObj6(lastObj){ + + let obj; + if(lastObj.player.type==='dizhu'){ + obj = this.getByObj1(lastObj); + }else{ + obj = this.getByObj3(lastObj); + } + + return obj; + + } + //接牌 playByObj(lastObj){ let obj; @@ -431,17 +440,103 @@ class AI{ obj = this.getByObj1(lastObj); } }else{ + if(this.player.next.type===this.player.type){ + obj = this.getByObj6(lastObj); + }else{ + if(this.player.next.pokerList.length===1){ + if(lastObj.player.type==='dizhu'){ + obj = this.getByObj4(lastObj); + }else{ + if(lastObj.type==='one'){ + let canNotGet = this.isPlayerCanNotGetOne(lastObj); + if(canNotGet){ + //pass + }else{ + obj = this.getByObj5(lastObj); + } + }else{ + //pass + } + } + }else{ + obj = this.getByObj6(lastObj); + } + } + } + if(!obj){ + obj = { + type: 'pass', + poker: ['pass'], + }; } this.player.deleteFromPokerListAndSendByObj(obj); } + isPlayerCanNotGetOne(obj){ + let allPoker = { + 3:0, + 4:0, + 5:0, + 6:0, + 7:0, + 8:0, + 9:0, + 10:0, + 11:0, + 12:0, + 13:0, + 14:0, + 15:0, + 16:0, + 17:0, + }; + let oldPokerList = this.game.oldPokerList; + for(let i=0; i0){ + for(let i=0; ilastObj.one[0].number){ + poker = classifyObj.one[i]; + break; + } + } + + } + + if(poker){ + obj = { + type: type, + poker: poker, + one: poker, + }; + } + }else if(type === 'two'){ + let poker; + + if(classifyObj.two.length>0){ + for(let i=0; ilastObj.two[0].number){ + poker = classifyObj.two[i]; + break; + } + } + } + + if(poker){ + obj = { + type: type, + poker: poker, + two: poker, + }; + } + }else if(type === 'three'){ + let poker; + + if(classifyObj.three.length>0){ + for(let i=0; ilastObj.three[0].number){ + if(classifyObj.three[i][0].number<=13){ + poker = classifyObj.three[i]; + } + break; + } + } + } + + if(poker){ + obj = { + type: type, + poker: poker, + three: poker, + }; + } + }else if(type === 'threeWithOne'){ + let pokerThree; + let one; + if(classifyObj.three.length>0){ + if(classifyObj.three.length>0){ + for(let i=0; ilastObj.three[0].number){ + if(classifyObj.three[i][0].number<=13){ + pokerThree = classifyObj.three[i]; + } + break; + } + } + } + } + + if(classifyObj.one.length>0){ + one = classifyObj.one[0]; + } + + if(pokerThree&&one){ + obj = { + type: type, + poker: pokerThree.concat(one), + three: pokerThree, + one: one, + }; + } + + }else if(type === 'threeWithTwo'){ + + let pokerThree; + let two; + if(classifyObj.three.length>0){ + if(classifyObj.three.length>0){ + for(let i=0; ilastObj.three[0].number){ + if(classifyObj.three[i][0].number<=13){ + pokerThree = classifyObj.three[i]; + } + break; + } + } + } + } + + if(classifyObj.two.length>0){ + two = classifyObj.two[0]; + } + + if(pokerThree&&two){ + obj = { + type: type, + poker: pokerThree.concat(two), + three: pokerThree, + two: two, + }; + } + + } + + return obj; + } + //最小接 不拆 getSmallestObjByObj(lastObj){ let classifyObj = this.player.classifyObj; @@ -510,7 +734,7 @@ class AI{ if(!poker){ if(lastObj.one[0].number<15&&classifyObj.poker15.length>0){ - poker = classifyObj.poker15[0]; + poker = classifyObj.poker15.slice(0,1); }else{ if(classifyObj.poker17.length<0||classifyObj.poker16.length<0){ if(lastObj.one[0].number<16&&classifyObj.poker16.length>0){ @@ -851,7 +1075,7 @@ class AI{ }else if(classifyObj.poker16.length>0){ poker = classifyObj.poker16; }else if(classifyObj.poker15.length>0){ - poker = classifyObj.poker15[0]; + poker = classifyObj.poker15.slice(0,1); }else{ poker = classifyObj.one[classifyObj.one.length-1]; } diff --git a/src/doudizhu/Game.js b/src/doudizhu/Game.js index 79a9b282266ea55b4287ad07be92e3ce0d64d8fd..849f85699585338bc5a549a3f31b24b2c54d24cd 100644 --- a/src/doudizhu/Game.js +++ b/src/doudizhu/Game.js @@ -56,7 +56,7 @@ class Game{ this.timeLoop(); this.currentPlayer = this.dizhu; if(this.currentPlayer.isRobot){ - this.currentPlayer.playByAI(); + this.currentPlayer.playByAI2(); } } @@ -69,7 +69,7 @@ class Game{ this.resetTime(); this.currentPlayer = this.currentPlayer.next; if(this.currentPlayer.isRobot){ - this.currentPlayer.playByAI(); + this.currentPlayer.playByAI2(); } }