AITemplate小模块合并至BOT模块并优化参数样式
修改所有之前的AITemplate至新格式 启用9s的hold开关(之前有开关但是没用) 准备好cc对接相关代码模板(不能用所以注释了,需要修改)
This commit is contained in:
1
main.lua
1
main.lua
@@ -83,7 +83,6 @@ USERS= require'parts.users'
|
|||||||
NET= require'parts.net'
|
NET= require'parts.net'
|
||||||
VK= require'parts.virtualKey'
|
VK= require'parts.virtualKey'
|
||||||
BOT= require'parts.bot'
|
BOT= require'parts.bot'
|
||||||
AIBUILDER= require'parts.AITemplate'
|
|
||||||
RSlist= require'parts.RSlist'DSCP=RSlist.TRS.centerPos
|
RSlist= require'parts.RSlist'DSCP=RSlist.TRS.centerPos
|
||||||
PLY= require'parts.player'
|
PLY= require'parts.player'
|
||||||
netPLY= require'parts.netPlayer'
|
netPLY= require'parts.netPlayer'
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
4deepShape
|
4deepShape
|
||||||
BlockedWells
|
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 ins,rem=table.insert,table.remove
|
||||||
local yield=coroutine.yield
|
local yield=coroutine.yield
|
||||||
|
|
||||||
@@ -121,7 +121,8 @@ local function getScore(field,cb,cy)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local bot_9s={}
|
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
|
while true do
|
||||||
--Thinking
|
--Thinking
|
||||||
yield()
|
yield()
|
||||||
@@ -135,7 +136,7 @@ function bot_9s.thread(P,keys)
|
|||||||
end
|
end
|
||||||
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
|
--Get block id
|
||||||
local bn
|
local bn
|
||||||
if ifhold==0 then
|
if ifhold==0 then
|
||||||
@@ -192,7 +193,7 @@ function bot_9s.thread(P,keys)
|
|||||||
--Check if time to change target
|
--Check if time to change target
|
||||||
yield()
|
yield()
|
||||||
if P.aiRND:random()<.00126 then
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
55
parts/bot/bot_cc.lua
Normal file
55
parts/bot/bot_cc.lua
Normal file
@@ -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
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
local rem=table.remove
|
local ins,rem=table.insert,table.remove
|
||||||
|
|
||||||
local baseBot={
|
local baseBot={
|
||||||
pushNewNext=NULL,
|
pushNewNext=NULL,
|
||||||
@@ -9,59 +9,103 @@ local baseBot={
|
|||||||
}
|
}
|
||||||
function baseBot.update(bot)
|
function baseBot.update(bot)
|
||||||
local P=bot.P
|
local P=bot.P
|
||||||
|
local keys=bot.keys
|
||||||
if P.control and P.waiting==-1 then
|
if P.control and P.waiting==-1 then
|
||||||
local keyQueue=bot.keys
|
|
||||||
bot.delay=bot.delay-1
|
bot.delay=bot.delay-1
|
||||||
if not keyQueue[1]then
|
if not keys[1]then
|
||||||
if bot.runningThread then
|
if bot.runningThread then
|
||||||
pcall(bot.runningThread)
|
pcall(bot.runningThread)
|
||||||
if not pcall(bot.runningThread)then
|
|
||||||
P:destroyBot()
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
P:act_hardDrop()
|
P:act_hardDrop()
|
||||||
end
|
end
|
||||||
elseif bot.delay<=0 then
|
elseif bot.delay<=0 then
|
||||||
bot.delay=bot.delay0*.5
|
bot.delay=bot.delay0*.5
|
||||||
P:pressKey(keyQueue[1])P:releaseKey(keyQueue[1])
|
P:pressKey(keys[1])P:releaseKey(keys[1])
|
||||||
rem(keyQueue,1)
|
rem(keys,1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function undefMethod(self,k)
|
local function undefMethod(self,k)
|
||||||
print('warn',"Undefined method: "..k)
|
print("Undefined method: "..k)
|
||||||
self[k]=NULL
|
self[k]=NULL
|
||||||
return NULL
|
return NULL
|
||||||
end
|
end
|
||||||
local botMeta={__index=undefMethod}
|
local botMeta={__index=undefMethod}
|
||||||
|
|
||||||
return{
|
local BOT={}
|
||||||
new=function(P,data)
|
|
||||||
local bot={P=P}
|
local AISpeed={60,50,40,30,20,14,10,6,4,3}
|
||||||
if data.type=="CC"then
|
function BOT.template(arg)
|
||||||
-- local ccBot=require"parts.bot.cc_wrapper"
|
if arg.type=='CC'then
|
||||||
-- setmetatable(bot,{__index=function(self,method)
|
if not arg.hold then arg.hold=false else arg.hold=true end
|
||||||
-- if ccBot[method]then
|
return{
|
||||||
-- ccBot[method](ccBot)
|
type='CC',
|
||||||
-- elseif baseBot[method]then
|
next=arg.next,
|
||||||
-- baseBot[method](self)
|
hold=arg.hold,
|
||||||
-- else
|
delay=AISpeed[arg.speedLV],
|
||||||
-- undefMethod(self,method)
|
["args.node"]=arg.node,
|
||||||
-- end
|
}
|
||||||
-- end})
|
elseif arg.type=='9S'then
|
||||||
setmetatable(bot,botMeta)
|
return{
|
||||||
elseif data.type=="9S"or true then--9s or else
|
type='9S',
|
||||||
TABLE.cover(baseBot,bot)
|
delay=math.floor(AISpeed[arg.speedLV]),
|
||||||
TABLE.cover(require"parts.bot.bot_9s",bot)
|
hold=arg.hold,
|
||||||
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
|
|
||||||
end
|
end
|
||||||
}
|
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
|
||||||
@@ -63,9 +63,9 @@ return{
|
|||||||
local AItype=GAME.modeEnv.opponent:sub(1,2)
|
local AItype=GAME.modeEnv.opponent:sub(1,2)
|
||||||
local AIlevel=tonumber(GAME.modeEnv.opponent:sub(-1))
|
local AIlevel=tonumber(GAME.modeEnv.opponent:sub(-1))
|
||||||
if AItype=='9S'then
|
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
|
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
|
||||||
|
|
||||||
for _,P in next,PLY_ALIVE do
|
for _,P in next,PLY_ALIVE do
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ return{
|
|||||||
local AIlevel=tonumber(GAME.modeEnv.opponent:sub(-1))
|
local AIlevel=tonumber(GAME.modeEnv.opponent:sub(-1))
|
||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
if AItype=='9S'then
|
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
|
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
|
||||||
end,
|
end,
|
||||||
mesDisp=function(P)
|
mesDisp=function(P)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ return{
|
|||||||
},
|
},
|
||||||
load=function()
|
load=function()
|
||||||
PLY.newPlayer(1)
|
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,
|
end,
|
||||||
score=function(P)return{P.stat.piece,P.stat.time}end,
|
score=function(P)return{P.stat.piece,P.stat.time}end,
|
||||||
scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end,
|
scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ return{
|
|||||||
},
|
},
|
||||||
load=function()
|
load=function()
|
||||||
PLY.newPlayer(1)
|
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,
|
end,
|
||||||
score=function(P)return{P.stat.piece,P.stat.time}end,
|
score=function(P)return{P.stat.piece,P.stat.time}end,
|
||||||
scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end,
|
scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ return{
|
|||||||
},
|
},
|
||||||
load=function()
|
load=function()
|
||||||
PLY.newPlayer(1)
|
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,
|
end,
|
||||||
score=function(P)return{P.stat.piece,P.stat.time}end,
|
score=function(P)return{P.stat.piece,P.stat.time}end,
|
||||||
scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end,
|
scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ return{
|
|||||||
},
|
},
|
||||||
load=function()
|
load=function()
|
||||||
PLY.newPlayer(1)
|
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,
|
end,
|
||||||
score=function(P)return{P.stat.piece,P.stat.time}end,
|
score=function(P)return{P.stat.piece,P.stat.time}end,
|
||||||
scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end,
|
scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ return{
|
|||||||
},
|
},
|
||||||
load=function()
|
load=function()
|
||||||
PLY.newPlayer(1)
|
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,
|
end,
|
||||||
score=function(P)return{P.stat.piece,P.stat.time}end,
|
score=function(P)return{P.stat.piece,P.stat.time}end,
|
||||||
scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end,
|
scoreDisp=function(D)return D[1].." Pieces "..STRING.time(D[2])end,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ return{
|
|||||||
},
|
},
|
||||||
load=function()
|
load=function()
|
||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
PLY.newAIPlayer(2,AIBUILDER('9S',4))
|
PLY.newAIPlayer(2,BOT.template{type='9S',speedLV=3,hold=true})
|
||||||
end,
|
end,
|
||||||
score=function(P)return{P.stat.time}end,
|
score=function(P)return{P.stat.time}end,
|
||||||
scoreDisp=function(D)return STRING.time(D[1])end,
|
scoreDisp=function(D)return STRING.time(D[1])end,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ return{
|
|||||||
},
|
},
|
||||||
load=function()
|
load=function()
|
||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
PLY.newAIPlayer(2,AIBUILDER('9S',6))
|
PLY.newAIPlayer(2,BOT.template{type='9S',speedLV=6,hold=true})
|
||||||
end,
|
end,
|
||||||
score=function(P)return{P.stat.time}end,
|
score=function(P)return{P.stat.time}end,
|
||||||
scoreDisp=function(D)return STRING.time(D[1])end,
|
scoreDisp=function(D)return STRING.time(D[1])end,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ return{
|
|||||||
},
|
},
|
||||||
load=function()
|
load=function()
|
||||||
PLY.newPlayer(1)
|
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,
|
end,
|
||||||
score=function(P)return{P.stat.time}end,
|
score=function(P)return{P.stat.time}end,
|
||||||
scoreDisp=function(D)return STRING.time(D[1])end,
|
scoreDisp=function(D)return STRING.time(D[1])end,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ return{
|
|||||||
},
|
},
|
||||||
load=function()
|
load=function()
|
||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
PLY.newAIPlayer(2,AIBUILDER('9S',5))
|
PLY.newAIPlayer(2,BOT.template{type='9S',speedLV=5,hold=true})
|
||||||
end,
|
end,
|
||||||
score=function(P)return{P.stat.time}end,
|
score=function(P)return{P.stat.time}end,
|
||||||
scoreDisp=function(D)return STRING.time(D[1])end,
|
scoreDisp=function(D)return STRING.time(D[1])end,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ return{
|
|||||||
},
|
},
|
||||||
load=function()
|
load=function()
|
||||||
PLY.newPlayer(1)
|
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,
|
end,
|
||||||
score=function(P)return{P.stat.time}end,
|
score=function(P)return{P.stat.time}end,
|
||||||
scoreDisp=function(D)return STRING.time(D[1])end,
|
scoreDisp=function(D)return STRING.time(D[1])end,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
local gc=love.graphics
|
|
||||||
local function selectTarget(P)
|
local function selectTarget(P)
|
||||||
if SETTING.swap then
|
if SETTING.swap then
|
||||||
for i=1,#P.keyPressing do
|
for i=1,#P.keyPressing do
|
||||||
@@ -30,7 +29,7 @@ return{
|
|||||||
ROYALEDATA.stage={30,20,15,10,5}
|
ROYALEDATA.stage={30,20,15,10,5}
|
||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
local L={}for i=1,49 do L[i]=true end
|
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
|
while t>0 do
|
||||||
local r=math.random(2,49)
|
local r=math.random(2,49)
|
||||||
if L[r]then L[r],t=false,t-1 end
|
if L[r]then L[r],t=false,t-1 end
|
||||||
@@ -38,17 +37,17 @@ return{
|
|||||||
local n=2
|
local n=2
|
||||||
for _=1,4 do for _=1,6 do
|
for _=1,4 do for _=1,6 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
for _=9,12 do for _=1,6 do
|
for _=9,12 do for _=1,6 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
local gc=love.graphics
|
|
||||||
local function selectTarget(P)
|
local function selectTarget(P)
|
||||||
if SETTING.swap then
|
if SETTING.swap then
|
||||||
for i=1,#P.keyPressing do
|
for i=1,#P.keyPressing do
|
||||||
@@ -30,7 +29,7 @@ return{
|
|||||||
ROYALEDATA.stage={30,20,15,10,5}
|
ROYALEDATA.stage={30,20,15,10,5}
|
||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
local L={}for i=1,49 do L[i]=true end
|
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
|
while t>0 do
|
||||||
local r=math.random(2,49)
|
local r=math.random(2,49)
|
||||||
if L[r]then L[r],t=false,t-1 end
|
if L[r]then L[r],t=false,t-1 end
|
||||||
@@ -38,17 +37,17 @@ return{
|
|||||||
local n=2
|
local n=2
|
||||||
for _=1,4 do for _=1,6 do
|
for _=1,4 do for _=1,6 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
for _=9,12 do for _=1,6 do
|
for _=9,12 do for _=1,6 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
local gc=love.graphics
|
|
||||||
local function selectTarget(P)
|
local function selectTarget(P)
|
||||||
if SETTING.swap then
|
if SETTING.swap then
|
||||||
for i=1,#P.keyPressing do
|
for i=1,#P.keyPressing do
|
||||||
@@ -30,7 +29,7 @@ return{
|
|||||||
ROYALEDATA.stage={30,20,15,10,5}
|
ROYALEDATA.stage={30,20,15,10,5}
|
||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
local L={}for i=1,49 do L[i]=true end
|
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
|
while t>0 do
|
||||||
local r=math.random(2,49)
|
local r=math.random(2,49)
|
||||||
if L[r]then L[r],t=false,t-1 end
|
if L[r]then L[r],t=false,t-1 end
|
||||||
@@ -38,17 +37,17 @@ return{
|
|||||||
local n=2
|
local n=2
|
||||||
for _=1,4 do for _=1,6 do
|
for _=1,4 do for _=1,6 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
for _=9,12 do for _=1,6 do
|
for _=9,12 do for _=1,6 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
local gc=love.graphics
|
|
||||||
local function selectTarget(P)
|
local function selectTarget(P)
|
||||||
if SETTING.swap then
|
if SETTING.swap then
|
||||||
for i=1,#P.keyPressing do
|
for i=1,#P.keyPressing do
|
||||||
@@ -30,7 +29,7 @@ return{
|
|||||||
ROYALEDATA.stage={75,50,35,20,10}
|
ROYALEDATA.stage={75,50,35,20,10}
|
||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
local L={}for i=1,100 do L[i]=true end
|
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
|
while t>0 do
|
||||||
local r=math.random(2,99)
|
local r=math.random(2,99)
|
||||||
if L[r]then L[r],t=false,t-1 end
|
if L[r]then L[r],t=false,t-1 end
|
||||||
@@ -38,17 +37,17 @@ return{
|
|||||||
local n=2
|
local n=2
|
||||||
for _=1,7 do for _=1,7 do
|
for _=1,7 do for _=1,7 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
for _=15,21 do for _=1,7 do
|
for _=15,21 do for _=1,7 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
local gc=love.graphics
|
|
||||||
local function selectTarget(P)
|
local function selectTarget(P)
|
||||||
if SETTING.swap then
|
if SETTING.swap then
|
||||||
for i=1,#P.keyPressing do
|
for i=1,#P.keyPressing do
|
||||||
@@ -30,7 +29,7 @@ return{
|
|||||||
ROYALEDATA.stage={75,50,35,20,10}
|
ROYALEDATA.stage={75,50,35,20,10}
|
||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
local L={}for i=1,100 do L[i]=true end
|
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
|
while t>0 do
|
||||||
local r=math.random(2,99)
|
local r=math.random(2,99)
|
||||||
if L[r]then L[r],t=false,t-1 end
|
if L[r]then L[r],t=false,t-1 end
|
||||||
@@ -38,17 +37,17 @@ return{
|
|||||||
local n=2
|
local n=2
|
||||||
for _=1,7 do for _=1,7 do
|
for _=1,7 do for _=1,7 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
for _=15,21 do for _=1,7 do
|
for _=15,21 do for _=1,7 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
local gc=love.graphics
|
|
||||||
local function selectTarget(P)
|
local function selectTarget(P)
|
||||||
if SETTING.swap then
|
if SETTING.swap then
|
||||||
for i=1,#P.keyPressing do
|
for i=1,#P.keyPressing do
|
||||||
@@ -30,7 +29,7 @@ return{
|
|||||||
ROYALEDATA.stage={75,50,35,20,10}
|
ROYALEDATA.stage={75,50,35,20,10}
|
||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
local L={}for i=1,100 do L[i]=true end
|
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
|
while t>0 do
|
||||||
local r=math.random(2,99)
|
local r=math.random(2,99)
|
||||||
if L[r]then L[r],t=false,t-1 end
|
if L[r]then L[r],t=false,t-1 end
|
||||||
@@ -38,17 +37,17 @@ return{
|
|||||||
local n=2
|
local n=2
|
||||||
for _=1,7 do for _=1,7 do
|
for _=1,7 do for _=1,7 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
for _=15,21 do for _=1,7 do
|
for _=15,21 do for _=1,7 do
|
||||||
if L[n]then
|
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
|
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
|
end
|
||||||
n=n+1
|
n=n+1
|
||||||
end end
|
end end
|
||||||
|
|||||||
@@ -828,13 +828,6 @@ function Player:hold(ifpre)
|
|||||||
SFX.play(ifpre and'prehold'or'hold')
|
SFX.play(ifpre and'prehold'or'hold')
|
||||||
end
|
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
|
self.stat.hold=self.stat.hold+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -853,6 +846,9 @@ function Player:getBlock(id,name,color)--Get a block object
|
|||||||
end
|
end
|
||||||
function Player:getNext(id)--Push a block to nextQueue
|
function Player:getNext(id)--Push a block to nextQueue
|
||||||
ins(self.nextQueue,self:getBlock(id))
|
ins(self.nextQueue,self:getBlock(id))
|
||||||
|
if self.bot then
|
||||||
|
self.bot:pushNewNext(id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
function Player:popNext(ifhold)--Pop nextQueue to hand
|
function Player:popNext(ifhold)--Pop nextQueue to hand
|
||||||
local ENV=self.gameEnv
|
local ENV=self.gameEnv
|
||||||
@@ -865,12 +861,6 @@ function Player:popNext(ifhold)--Pop nextQueue to hand
|
|||||||
|
|
||||||
self.cur=rem(self.nextQueue,1)
|
self.cur=rem(self.nextQueue,1)
|
||||||
self.newNext()
|
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
|
if self.cur then
|
||||||
self.pieceCount=self.pieceCount+1
|
self.pieceCount=self.pieceCount+1
|
||||||
|
|
||||||
@@ -1519,10 +1509,6 @@ function Player:loadAI(data)--Load AI params
|
|||||||
self.bot=BOT.new(self,data)
|
self.bot=BOT.new(self,data)
|
||||||
self.bot.data=data
|
self.bot.data=data
|
||||||
end
|
end
|
||||||
function Player:reloadAI()--Load AI params
|
|
||||||
assert(self.bot,"Cannot reload AI before loading one!")
|
|
||||||
self.bot=BOT.load(self.bot.data)
|
|
||||||
end
|
|
||||||
--------------------------</Methods>--------------------------
|
--------------------------</Methods>--------------------------
|
||||||
|
|
||||||
--------------------------<Ticks>--------------------------
|
--------------------------<Ticks>--------------------------
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ local int,abs=math.floor,math.abs
|
|||||||
local rem=table.remove
|
local rem=table.remove
|
||||||
local assert,resume,status=assert,coroutine.resume,coroutine.status
|
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 PLY_ALIVE=PLY_ALIVE
|
||||||
|
|
||||||
local function update_misc(P,dt)
|
local function update_misc(P,dt)
|
||||||
|
|||||||
Reference in New Issue
Block a user