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