diff --git a/main.lua b/main.lua index f8e2a15b..8f888856 100644 --- a/main.lua +++ b/main.lua @@ -83,7 +83,6 @@ USERS= require'parts.users' NET= require'parts.net' VK= require'parts.virtualKey' BOT= require'parts.bot' -AIBUILDER= require'parts.AITemplate' RSlist= require'parts.RSlist'DSCP=RSlist.TRS.centerPos PLY= require'parts.player' netPLY= require'parts.netPlayer' diff --git a/parts/AITemplate.lua b/parts/AITemplate.lua deleted file mode 100644 index d75176af..00000000 --- a/parts/AITemplate.lua +++ /dev/null @@ -1,19 +0,0 @@ -local AISpeed={60,50,40,30,20,14,10,6,4,3} -return function(type,speedLV,next,hold,node) - if type=='CC'then - if not hold then hold=false else hold=true end - return{ - type='CC', - next=next, - hold=hold, - delay=AISpeed[speedLV], - node=node, - } - elseif type=='9S'then - return{ - type='9S', - delay=math.floor(AISpeed[speedLV]), - hold=hold, - } - end -end \ No newline at end of file diff --git a/parts/bot/bot_9s.lua b/parts/bot/bot_9s.lua index d6799489..faf553d5 100644 --- a/parts/bot/bot_9s.lua +++ b/parts/bot/bot_9s.lua @@ -11,7 +11,7 @@ 4deepShape BlockedWells ]] -local min,abs,rnd=math.min,math.abs,math.random +local min,abs=math.min,math.abs local ins,rem=table.insert,table.remove local yield=coroutine.yield @@ -121,7 +121,8 @@ local function getScore(field,cb,cy) end local bot_9s={} -function bot_9s.thread(P,keys) +function bot_9s.thread(bot) + local P,data,keys=bot.P,bot.data,bot.keys while true do --Thinking yield() @@ -135,7 +136,7 @@ function bot_9s.thread(P,keys) end end - for ifhold=0,P.gameEnv.holdCount>0 and 1 or 0 do + for ifhold=0,data.hold and P.gameEnv.holdCount>0 and 1 or 0 do --Get block id local bn if ifhold==0 then @@ -192,7 +193,7 @@ function bot_9s.thread(P,keys) --Check if time to change target yield() if P.aiRND:random()<.00126 then - P:changeAtkMode(rnd()<.85 and 1 or #P.atker>3 and 4 or rnd()<.3 and 2 or 3) + P:changeAtkMode(P.aiRND:random()<.85 and 1 or #P.atker>3 and 4 or P.aiRND:random()<.3 and 2 or 3) end end end diff --git a/parts/bot/bot_cc.lua b/parts/bot/bot_cc.lua new file mode 100644 index 00000000..0d6eaa02 --- /dev/null +++ b/parts/bot/bot_cc.lua @@ -0,0 +1,55 @@ +--[[ControlID: + 1~5:mL,mR,rR,rL,rF, + 6~10:hD,sD,H,A,R, + 11~13:LL,RR,DD +]] +local ins,rem=table.insert,table.remove +local yield=coroutine.yield +local bot_cc={} +function bot_cc:pushNewNext(id) + self.bot:addNext(rem(self.nexts,1)) + ins(self.nexts,id) +end +function bot_cc:thread() + local P,keys=self.P,self.keys + local ccBot=self.ccBot + while true do + --Start thinking + yield() + ccBot:think() + + --Poll keys + local success,result,dest,hold,move + repeat + yield() + success,result,dest,hold,move=ccBot:getMove() + until not success or result==0 or result==2 + if not success then break end + if result==2 then + break + elseif result==0 then + dest[5],dest[6]=dest[1][1],dest[1][2] + dest[7],dest[8]=dest[2][1],dest[2][2] + dest[1],dest[2]=dest[3][1],dest[3][2] + dest[3],dest[4]=dest[4][1],dest[4][2] + P.AI_dest=dest + if hold then keys[1]=8 end--Hold + while move[1]do + local m=rem(move,1) + if m<4 then + ins(keys,m+1) + elseif not P.AIdata._20G then + ins(keys,13) + end + end + ins(keys,6) + end + + --Check if time to change target + yield() + if P.aiRND:random()<.00126 then + P:changeAtkMode(P.aiRND:random()<.85 and 1 or #P.atker>3 and 4 or P.aiRND:random()<.3 and 2 or 3) + end + end +end +return bot_cc \ No newline at end of file diff --git a/parts/bot/init.lua b/parts/bot/init.lua index 71458734..d73ccc71 100644 --- a/parts/bot/init.lua +++ b/parts/bot/init.lua @@ -1,4 +1,4 @@ -local rem=table.remove +local ins,rem=table.insert,table.remove local baseBot={ pushNewNext=NULL, @@ -9,59 +9,103 @@ local baseBot={ } function baseBot.update(bot) local P=bot.P + local keys=bot.keys if P.control and P.waiting==-1 then - local keyQueue=bot.keys bot.delay=bot.delay-1 - if not keyQueue[1]then + if not keys[1]then if bot.runningThread then pcall(bot.runningThread) - if not pcall(bot.runningThread)then - P:destroyBot() - end else P:act_hardDrop() end elseif bot.delay<=0 then bot.delay=bot.delay0*.5 - P:pressKey(keyQueue[1])P:releaseKey(keyQueue[1]) - rem(keyQueue,1) + P:pressKey(keys[1])P:releaseKey(keys[1]) + rem(keys,1) end end end local function undefMethod(self,k) - print('warn',"Undefined method: "..k) + print("Undefined method: "..k) self[k]=NULL return NULL end local botMeta={__index=undefMethod} -return{ - new=function(P,data) - local bot={P=P} - if data.type=="CC"then - -- local ccBot=require"parts.bot.cc_wrapper" - -- setmetatable(bot,{__index=function(self,method) - -- if ccBot[method]then - -- ccBot[method](ccBot) - -- elseif baseBot[method]then - -- baseBot[method](self) - -- else - -- undefMethod(self,method) - -- end - -- end}) - setmetatable(bot,botMeta) - elseif data.type=="9S"or true then--9s or else - TABLE.cover(baseBot,bot) - TABLE.cover(require"parts.bot.bot_9s",bot) - bot.P:setRS('TRS') - bot.runningThread=coroutine.wrap(bot.thread) - bot.keys={} - bot.delay=data.delay - bot.delay0=data.delay - bot.runningThread(P,bot.keys) - setmetatable(bot,botMeta) - end - return bot +local BOT={} + +local AISpeed={60,50,40,30,20,14,10,6,4,3} +function BOT.template(arg) + if arg.type=='CC'then + if not arg.hold then arg.hold=false else arg.hold=true end + return{ + type='CC', + next=arg.next, + hold=arg.hold, + delay=AISpeed[arg.speedLV], + ["args.node"]=arg.node, + } + elseif arg.type=='9S'then + return{ + type='9S', + delay=math.floor(AISpeed[arg.speedLV]), + hold=arg.hold, + } end -} \ No newline at end of file +end + +function BOT.new(P,data) + local bot={P=P,data=data} + if data.type=="CC"then + -- P:setRS('SRS') + -- bot.keys={} + -- bot.nexts={} + -- bot.delay=data.delay + -- bot.delay0=data.delay + -- if P.gameEnv.holdCount and P.gameEnv.holdCount>1 then P:setHold(1)end + + -- local cc=require"parts.bot.cc_wrapper" + -- local opt,wei=cc.getConf() + -- wei:fastWeights() + -- opt:setHold(P.AIdata.hold) + -- opt:set20G(P.AIdata._20G) + -- opt:setBag(P.AIdata.bag=='bag') + -- opt:setNode(P.AIdata.node) + -- bot.ccBot=cc.new(opt,wei) + -- local cc_lua=require"parts.bot.bot_cc" + -- setmetatable(bot,{__index=function(self,k) + -- if self.ccBot[k]then + -- self.ccBot[k](self.ccBot) + -- elseif cc_lua[k]then + -- cc_lua[k](self) + -- elseif baseBot[k]then + -- baseBot[k](self) + -- end + -- end}) + + -- for i,B in next,P.gameEnv.nextQueue do + -- if i<=data.next then + -- bot:addNext(B.id) + -- else + -- ins(bot.nexts,B.id) + -- end + -- end + -- bot.runningThread=coroutine.wrap(cc_lua.thread) + -- bot.runningThread(bot) + setmetatable(bot,botMeta) + elseif data.type=="9S"or true then--9s or else + TABLE.cover(baseBot,bot) + TABLE.cover(require"parts.bot.bot_9s",bot) + P:setRS('TRS') + bot.keys={} + bot.delay=data.delay + bot.delay0=data.delay + bot.runningThread=coroutine.wrap(bot.thread) + bot.runningThread(bot) + setmetatable(bot,botMeta) + end + return bot +end + +return BOT \ No newline at end of file diff --git a/parts/modes/custom_clear.lua b/parts/modes/custom_clear.lua index 0baff7bd..d1e0deef 100644 --- a/parts/modes/custom_clear.lua +++ b/parts/modes/custom_clear.lua @@ -63,9 +63,9 @@ return{ local AItype=GAME.modeEnv.opponent:sub(1,2) local AIlevel=tonumber(GAME.modeEnv.opponent:sub(-1)) if AItype=='9S'then - PLY.newAIPlayer(2,AIBUILDER('9S',2*AIlevel)) + PLY.newAIPlayer(2,BOT.template{type='9S',speedLV=2*AIlevel,hold=true}) elseif AItype=='CC'then - PLY.newAIPlayer(2,AIBUILDER('CC',2*AIlevel-1,math.floor(AIlevel*.5+1),true,20000+5000*AIlevel)) + PLY.newAIPlayer(2,BOT.template{type='CC',speedLV=2*AIlevel-1,next=math.floor(AIlevel*.5+1),hold=true,node=20000+5000*AIlevel}) end for _,P in next,PLY_ALIVE do diff --git a/parts/modes/custom_puzzle.lua b/parts/modes/custom_puzzle.lua index b716e1b6..6d16da8a 100644 --- a/parts/modes/custom_puzzle.lua +++ b/parts/modes/custom_puzzle.lua @@ -44,9 +44,9 @@ return{ local AIlevel=tonumber(GAME.modeEnv.opponent:sub(-1)) PLY.newPlayer(1) if AItype=='9S'then - PLY.newAIPlayer(2,AIBUILDER('9S',2*AIlevel)) + PLY.newAIPlayer(2,BOT.template{type='9S',speedLV=2*AIlevel,hold=true}) elseif AItype=='CC'then - PLY.newAIPlayer(2,AIBUILDER('CC',2*AIlevel-1,math.floor(AIlevel*.5+1),true,20000+5000*AIlevel)) + PLY.newAIPlayer(2,BOT.template{type='CC',speedLV=2*AIlevel-1,next=math.floor(AIlevel*.5+1),hold=true,node=20000+5000*AIlevel}) end end, mesDisp=function(P) diff --git a/parts/modes/round_e.lua b/parts/modes/round_e.lua index 04cb5fe6..dcfb9f63 100644 --- a/parts/modes/round_e.lua +++ b/parts/modes/round_e.lua @@ -23,7 +23,7 @@ return{ }, load=function() PLY.newPlayer(1) - PLY.newAIPlayer(2,AIBUILDER('CC',8,1,true,8000)) + PLY.newAIPlayer(2,BOT.template{type='CC',speedLV=8,next=1,hold=true,node=8000}) end, score=function(P)return{P.stat.piece,P.stat.time}end, scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end, diff --git a/parts/modes/round_h.lua b/parts/modes/round_h.lua index 5a142a01..4fb4cf99 100644 --- a/parts/modes/round_h.lua +++ b/parts/modes/round_h.lua @@ -23,7 +23,7 @@ return{ }, load=function() PLY.newPlayer(1) - PLY.newAIPlayer(2,AIBUILDER('CC',8,2,true,16000)) + PLY.newAIPlayer(2,BOT.template{type='CC',speedLV=8,next=2,hold=true,node=16000}) end, score=function(P)return{P.stat.piece,P.stat.time}end, scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end, diff --git a/parts/modes/round_l.lua b/parts/modes/round_l.lua index 08542fd7..6d48392a 100644 --- a/parts/modes/round_l.lua +++ b/parts/modes/round_l.lua @@ -23,7 +23,7 @@ return{ }, load=function() PLY.newPlayer(1) - PLY.newAIPlayer(2,AIBUILDER('CC',8,3,true,26000)) + PLY.newAIPlayer(2,BOT.template{type='CC',speedLV=8,next=3,hold=true,node=26000}) end, score=function(P)return{P.stat.piece,P.stat.time}end, scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end, diff --git a/parts/modes/round_n.lua b/parts/modes/round_n.lua index 9250898f..437a3970 100644 --- a/parts/modes/round_n.lua +++ b/parts/modes/round_n.lua @@ -23,7 +23,7 @@ return{ }, load=function() PLY.newPlayer(1) - PLY.newAIPlayer(2,AIBUILDER('CC',8,1,true,13000)) + PLY.newAIPlayer(2,BOT.template{type='CC',speedLV=8,next=1,hold=true,node=13000}) end, score=function(P)return{P.stat.piece,P.stat.time}end, scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end, diff --git a/parts/modes/round_u.lua b/parts/modes/round_u.lua index f3d33960..8b6205a2 100644 --- a/parts/modes/round_u.lua +++ b/parts/modes/round_u.lua @@ -23,7 +23,7 @@ return{ }, load=function() PLY.newPlayer(1) - PLY.newAIPlayer(2,AIBUILDER('CC',8,4,true,40000)) + PLY.newAIPlayer(2,BOT.template{type='CC',speedLV=8,next=4,hold=true,node=40000}) end, score=function(P)return{P.stat.piece,P.stat.time}end, scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end, diff --git a/parts/modes/solo_e.lua b/parts/modes/solo_e.lua index 70772d1b..372713d0 100644 --- a/parts/modes/solo_e.lua +++ b/parts/modes/solo_e.lua @@ -9,7 +9,7 @@ return{ }, load=function() PLY.newPlayer(1) - PLY.newAIPlayer(2,AIBUILDER('9S',4)) + PLY.newAIPlayer(2,BOT.template{type='9S',speedLV=3,hold=true}) end, score=function(P)return{P.stat.time}end, scoreDisp=function(D)return STRING.time(D[1])end, diff --git a/parts/modes/solo_h.lua b/parts/modes/solo_h.lua index 89283abc..5d82f395 100644 --- a/parts/modes/solo_h.lua +++ b/parts/modes/solo_h.lua @@ -9,7 +9,7 @@ return{ }, load=function() PLY.newPlayer(1) - PLY.newAIPlayer(2,AIBUILDER('9S',6)) + PLY.newAIPlayer(2,BOT.template{type='9S',speedLV=6,hold=true}) end, score=function(P)return{P.stat.time}end, scoreDisp=function(D)return STRING.time(D[1])end, diff --git a/parts/modes/solo_l.lua b/parts/modes/solo_l.lua index 81c315ed..db1b7f62 100644 --- a/parts/modes/solo_l.lua +++ b/parts/modes/solo_l.lua @@ -9,7 +9,7 @@ return{ }, load=function() PLY.newPlayer(1) - PLY.newAIPlayer(2,AIBUILDER('CC',6,2,true,30000)) + PLY.newAIPlayer(2,BOT.template{type='CC',speedLV=6,next=2,hold=true,node=30000}) end, score=function(P)return{P.stat.time}end, scoreDisp=function(D)return STRING.time(D[1])end, diff --git a/parts/modes/solo_n.lua b/parts/modes/solo_n.lua index c075f673..eab6ef7a 100644 --- a/parts/modes/solo_n.lua +++ b/parts/modes/solo_n.lua @@ -9,7 +9,7 @@ return{ }, load=function() PLY.newPlayer(1) - PLY.newAIPlayer(2,AIBUILDER('9S',5)) + PLY.newAIPlayer(2,BOT.template{type='9S',speedLV=5,hold=true}) end, score=function(P)return{P.stat.time}end, scoreDisp=function(D)return STRING.time(D[1])end, diff --git a/parts/modes/solo_u.lua b/parts/modes/solo_u.lua index b0ae5a89..86800834 100644 --- a/parts/modes/solo_u.lua +++ b/parts/modes/solo_u.lua @@ -9,7 +9,7 @@ return{ }, load=function() PLY.newPlayer(1) - PLY.newAIPlayer(2,AIBUILDER('CC',7,3,true,50000)) + PLY.newAIPlayer(2,BOT.template{type='CC',speedLV=7,next=3,hold=true,node=50000}) end, score=function(P)return{P.stat.time}end, scoreDisp=function(D)return STRING.time(D[1])end, diff --git a/parts/modes/techmino49_e.lua b/parts/modes/techmino49_e.lua index 78fbab3e..90531d77 100644 --- a/parts/modes/techmino49_e.lua +++ b/parts/modes/techmino49_e.lua @@ -1,4 +1,3 @@ -local gc=love.graphics local function selectTarget(P) if SETTING.swap then for i=1,#P.keyPressing do @@ -30,7 +29,7 @@ return{ ROYALEDATA.stage={30,20,15,10,5} PLY.newPlayer(1) local L={}for i=1,49 do L[i]=true end - local t=CC and 2 or 0 + local t=2 while t>0 do local r=math.random(2,49) if L[r]then L[r],t=false,t-1 end @@ -38,17 +37,17 @@ return{ local n=2 for _=1,4 do for _=1,6 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(4,6)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(4,6),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(2,4),2,true,20000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(2,4),next=2,hold=true,node=20000},true) end n=n+1 end end for _=9,12 do for _=1,6 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(4,5)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(4,5),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(3,5),2,true,20000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(3,5),next=2,hold=true,node=20000},true) end n=n+1 end end diff --git a/parts/modes/techmino49_h.lua b/parts/modes/techmino49_h.lua index b4197c1e..3a05e8d5 100644 --- a/parts/modes/techmino49_h.lua +++ b/parts/modes/techmino49_h.lua @@ -1,4 +1,3 @@ -local gc=love.graphics local function selectTarget(P) if SETTING.swap then for i=1,#P.keyPressing do @@ -30,7 +29,7 @@ return{ ROYALEDATA.stage={30,20,15,10,5} PLY.newPlayer(1) local L={}for i=1,49 do L[i]=true end - local t=CC and 4 or 0 + local t=4 while t>0 do local r=math.random(2,49) if L[r]then L[r],t=false,t-1 end @@ -38,17 +37,17 @@ return{ local n=2 for _=1,4 do for _=1,6 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(4,8)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(4,8),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(3,6),3,true,30000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(3,6),next=3,hold=true,node=30000},true) end n=n+1 end end for _=9,12 do for _=1,6 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(4,7)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(4,7),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(4,6),3,true,30000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(4,6),next=3,hold=true,node=30000},true) end n=n+1 end end diff --git a/parts/modes/techmino49_u.lua b/parts/modes/techmino49_u.lua index 0264f5ef..cc4aafeb 100644 --- a/parts/modes/techmino49_u.lua +++ b/parts/modes/techmino49_u.lua @@ -1,4 +1,3 @@ -local gc=love.graphics local function selectTarget(P) if SETTING.swap then for i=1,#P.keyPressing do @@ -30,7 +29,7 @@ return{ ROYALEDATA.stage={30,20,15,10,5} PLY.newPlayer(1) local L={}for i=1,49 do L[i]=true end - local t=CC and 6 or 0 + local t=6 while t>0 do local r=math.random(2,49) if L[r]then L[r],t=false,t-1 end @@ -38,17 +37,17 @@ return{ local n=2 for _=1,4 do for _=1,6 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(8,10)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(8,10),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(4,7),3,true,40000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(4,7),next=3,hold=true,node=40000},true) end n=n+1 end end for _=9,12 do for _=1,6 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(8,9)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(8,9),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(5,8),3,true,40000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(5,8),next=3,hold=true,node=40000},true) end n=n+1 end end diff --git a/parts/modes/techmino99_e.lua b/parts/modes/techmino99_e.lua index c0018b79..bf07b436 100644 --- a/parts/modes/techmino99_e.lua +++ b/parts/modes/techmino99_e.lua @@ -1,4 +1,3 @@ -local gc=love.graphics local function selectTarget(P) if SETTING.swap then for i=1,#P.keyPressing do @@ -30,7 +29,7 @@ return{ ROYALEDATA.stage={75,50,35,20,10} PLY.newPlayer(1) local L={}for i=1,100 do L[i]=true end - local t=CC and 4 or 0 + local t=4 while t>0 do local r=math.random(2,99) if L[r]then L[r],t=false,t-1 end @@ -38,17 +37,17 @@ return{ local n=2 for _=1,7 do for _=1,7 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(4,6)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(4,6),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(2,4),2,true,20000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(2,4),next=2,hold=true,node=20000},true) end n=n+1 end end for _=15,21 do for _=1,7 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(4,5)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(4,5),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(3,5),2,true,20000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(3,5),next=2,hold=true,node=20000},true) end n=n+1 end end diff --git a/parts/modes/techmino99_h.lua b/parts/modes/techmino99_h.lua index feecfaea..87eaedb8 100644 --- a/parts/modes/techmino99_h.lua +++ b/parts/modes/techmino99_h.lua @@ -1,4 +1,3 @@ -local gc=love.graphics local function selectTarget(P) if SETTING.swap then for i=1,#P.keyPressing do @@ -30,7 +29,7 @@ return{ ROYALEDATA.stage={75,50,35,20,10} PLY.newPlayer(1) local L={}for i=1,100 do L[i]=true end - local t=CC and 4 or 0 + local t=4 while t>0 do local r=math.random(2,99) if L[r]then L[r],t=false,t-1 end @@ -38,17 +37,17 @@ return{ local n=2 for _=1,7 do for _=1,7 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(4,8)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(4,8),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(3,6),3,true,30000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(3,6),next=3,hold=true,node=30000},true) end n=n+1 end end for _=15,21 do for _=1,7 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(4,7)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(4,7),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(4,6),3,true,30000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(4,6),next=3,hold=true,node=30000},true) end n=n+1 end end diff --git a/parts/modes/techmino99_u.lua b/parts/modes/techmino99_u.lua index edee6ecc..645c3ed3 100644 --- a/parts/modes/techmino99_u.lua +++ b/parts/modes/techmino99_u.lua @@ -1,4 +1,3 @@ -local gc=love.graphics local function selectTarget(P) if SETTING.swap then for i=1,#P.keyPressing do @@ -30,7 +29,7 @@ return{ ROYALEDATA.stage={75,50,35,20,10} PLY.newPlayer(1) local L={}for i=1,100 do L[i]=true end - local t=CC and 4 or 0 + local t=4 while t>0 do local r=math.random(2,99) if L[r]then L[r],t=false,t-1 end @@ -38,17 +37,17 @@ return{ local n=2 for _=1,7 do for _=1,7 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(8,10)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(8,10),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(4,7),3,true,40000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(4,7),next=3,hold=true,node=40000},true) end n=n+1 end end for _=15,21 do for _=1,7 do if L[n]then - PLY.newAIPlayer(n,AIBUILDER('9S',math.random(8,9)),true) + PLY.newAIPlayer(n,BOT.template{type='9S',speedLV=math.random(8,9),hold=true}) else - PLY.newAIPlayer(n,AIBUILDER('CC',math.random(5,8),3,true,40000),true) + PLY.newAIPlayer(n,BOT.template{type='CC',speedLV=math.random(5,8),next=3,hold=true,node=40000},true) end n=n+1 end end diff --git a/parts/player/player.lua b/parts/player/player.lua index 103d98b3..28a2e439 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -828,13 +828,6 @@ function Player:hold(ifpre) SFX.play(ifpre and'prehold'or'hold') end - if self.bot then - local next=self.nextQueue[ENV.nextCount] - if next then - self.bot:pushNewNext(next.id) - end - end - self.stat.hold=self.stat.hold+1 end end @@ -853,6 +846,9 @@ function Player:getBlock(id,name,color)--Get a block object end function Player:getNext(id)--Push a block to nextQueue ins(self.nextQueue,self:getBlock(id)) + if self.bot then + self.bot:pushNewNext(id) + end end function Player:popNext(ifhold)--Pop nextQueue to hand local ENV=self.gameEnv @@ -865,12 +861,6 @@ function Player:popNext(ifhold)--Pop nextQueue to hand self.cur=rem(self.nextQueue,1) self.newNext() - if self.bot then - local next=self.nextQueue[ENV.nextCount] - if next then - self.bot:pushNewNext(next.id) - end - end if self.cur then self.pieceCount=self.pieceCount+1 @@ -1519,10 +1509,6 @@ function Player:loadAI(data)--Load AI params self.bot=BOT.new(self,data) self.bot.data=data end -function Player:reloadAI()--Load AI params - assert(self.bot,"Cannot reload AI before loading one!") - self.bot=BOT.load(self.bot.data) -end ---------------------------------------------------- ---------------------------------------------------- diff --git a/parts/player/update.lua b/parts/player/update.lua index 050d26c0..26709795 100644 --- a/parts/player/update.lua +++ b/parts/player/update.lua @@ -3,7 +3,7 @@ local int,abs=math.floor,math.abs local rem=table.remove local assert,resume,status=assert,coroutine.resume,coroutine.status -local TEXT,GAME,CC=TEXT,GAME,CC +local TEXT,GAME=TEXT,GAME local PLY_ALIVE=PLY_ALIVE local function update_misc(P,dt)