From e7b4518d73f4623a3e892234809767689f40c1a3 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Wed, 1 Dec 2021 15:46:12 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=AD=A6=E5=91=8A=EF=BC=9A=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E6=B5=8B=E8=AF=95=E3=80=91=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E8=83=BDhold/=E7=A7=BB=E5=8A=A8/=E6=97=8B?= =?UTF-8?q?=E8=BD=AC=E6=96=B9=E5=9D=97=E7=9A=84=E6=9D=A1=E4=BB=B6=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcc=E5=A4=8D=E6=B4=BB=E5=90=8E=E5=B0=8Fbug=20?= =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/bot/bot_cc.lua | 4 ++-- parts/bot/init.lua | 21 +++++++++++++-------- parts/player/player.lua | 21 +++++++++++---------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/parts/bot/bot_cc.lua b/parts/bot/bot_cc.lua index da3ac2c2..ec2c615c 100644 --- a/parts/bot/bot_cc.lua +++ b/parts/bot/bot_cc.lua @@ -25,8 +25,8 @@ function bot_cc:revive() self.P:loadAI(self.data) end function bot_cc:pushNewNext(id) - self.ccBot:addNext(rem(self.nexts,1)) - ins(self.nexts,id) + self.ccBot:addNext(rem(self.bufferedNexts,1)) + ins(self.bufferedNexts,id) end function bot_cc:thread() local P,keys=self.P,self.keys diff --git a/parts/bot/init.lua b/parts/bot/init.lua index 27d9e60b..4df42abf 100644 --- a/parts/bot/init.lua +++ b/parts/bot/init.lua @@ -12,7 +12,7 @@ local baseBot={ function baseBot.update(bot) local P=bot.P local keys=bot.keys - if P.control and P.waiting==0 then + if P.control and P.cur then bot.delay=bot.delay-1 if not keys[1]then if bot.runningThread then @@ -85,7 +85,7 @@ function BOT.new(P,data) if data.type=="CC"then P:setRS('SRS') bot.keys={} - bot.nexts={} + bot.bufferedNexts={} bot.delay=data.delay bot.delay0=data.delay if P.gameEnv.holdCount>1 then @@ -109,20 +109,25 @@ function BOT.new(P,data) return self.ccBot[k]and function(_,...)self.ccBot[k](self.ccBot,...)end or cc_lua[k]and function(_,...)cc_lua[k](self,...)end or - baseBot[k]and baseBot[k]or - error("No actions called "..k) + assert(baseBot[k],"No CC action called "..k) end}) - for i,B in next,P.nextQueue do - if i<=data.next then + local pushed=0 + if P.cur then + bot:addNext(P.cur.id) + pushed=pushed+1 + end + for _,B in next,P.nextQueue do + if pushed<=data.next then bot:addNext(B.id) + pushed=pushed+1 else - ins(bot.nexts,B.id) + ins(bot.bufferedNexts,B.id) end end bot.runningThread=coroutine.wrap(cc_lua.thread) bot.runningThread(bot) - elseif data.type=="9S"or true then--9s or else + else--if data.type=="9S"then--9s or else TABLE.cover(baseBot,bot) TABLE.cover(require"parts.bot.bot_9s",bot) P:setRS('TRS') diff --git a/parts/player/player.lua b/parts/player/player.lua index 8dc2d0c3..fe949df5 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -220,7 +220,7 @@ function Player:act_moveLeft(auto) self.ctrlCount=self.ctrlCount+1 end self.movDir=-1 - if self.control and self.waiting==0 then + if self.cur then if self.cur and not self:ifoverlap(self.cur.bk,self.curX-1,self.curY)then self:createMoveFX('left') self.curX=self.curX-1 @@ -241,7 +241,7 @@ function Player:act_moveRight(auto) self.ctrlCount=self.ctrlCount+1 end self.movDir=1 - if self.control and self.waiting==0 then + if self.cur then if self.cur and not self:ifoverlap(self.cur.bk,self.curX+1,self.curY)then self:createMoveFX('right') self.curX=self.curX+1 @@ -258,21 +258,21 @@ function Player:act_moveRight(auto) end end function Player:act_rotRight() - if self.control and self.cur then + if self.cur then self.ctrlCount=self.ctrlCount+1 self:spin(1) self.keyPressing[3]=false end end function Player:act_rotLeft() - if self.control and self.cur then + if self.cur then self.ctrlCount=self.ctrlCount+1 self:spin(3) self.keyPressing[4]=false end end function Player:act_rot180() - if self.control and self.cur then + if self.cur then self.ctrlCount=self.ctrlCount+2 self:spin(2) self.keyPressing[5]=false @@ -280,7 +280,7 @@ function Player:act_rot180() end function Player:act_hardDrop() local ENV=self.gameEnv - if self.control and self.cur then + if self.cur then if self.lastPiece.autoLock and self.frameRun-self.lastPiece.frameself.ghoY then self.curY=self.curY-1 self:freshBlock('fresh') @@ -317,7 +317,8 @@ function Player:act_softDrop() end end function Player:act_hold() - if self.control and self.cur then + print(self.control,self.cur) + if self.cur then if self:hold()then self.keyPressing[8]=false end @@ -1325,7 +1326,7 @@ function Player:hold_swap(ifpre) self.stat.hold=self.stat.hold+1 end function Player:hold(ifpre) - if self.holdTime>0 and(ifpre or self.falling==0 and self.waiting==0)then + if self.holdTime>0 and(self.cur or ifpre)then if self.gameEnv.holdMode=='hold'then self:hold_norm(ifpre) elseif self.gameEnv.holdMode=='swap'then @@ -2048,7 +2049,7 @@ do return _cc,_gbcc end end -function Player:loadAI(data)--Load AI params +function Player:loadAI(data)--Load AI with params self.bot=BOT.new(self,data) self.bot.data=data end