From 17d670a1babe208a263b2c24f3db474b5783dbbd Mon Sep 17 00:00:00 2001 From: Gompyn Date: Wed, 29 Jul 2020 14:47:49 +0800 Subject: [PATCH 1/3] adapt cold-clear 45d5276 --- parts/ai.lua | 12 +++++++----- parts/player.lua | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/parts/ai.lua b/parts/ai.lua index 5360ebbb..30623400 100644 --- a/parts/ai.lua +++ b/parts/ai.lua @@ -18,7 +18,7 @@ local Timer=love.timer.getTime local blockPos={4,4,4,4,4,5,4} local scs={{1,2},{1,2},{1,2},{1,2},{1,2},{1.5,1.5},{0.5,2.5}} -------------------------------------------------Cold clear -local CCblockID={4,3,6,5,1,2,0} +local CCblockID={6,5,4,3,2,1,0} if system=="Windows"then require("CCloader") BOT={ @@ -29,12 +29,12 @@ if system=="Windows"then addNext= cc.add_next_piece_async ,--(bot,piece) update= cc.reset_async ,--(bot,field,b2b,combo) think= cc.request_next_move ,--(bot) - getMove= cc.poll_next_move ,--(bot)success,hold,move - ifDead= cc.is_dead_async ,--(bot)dead + getMove= cc.poll_next_move ,--(bot)success,dest,hold,move destroy= cc.destroy_async ,--(bot) setHold= cc.set_hold ,--(opt,bool) set20G= cc.set_20g ,--(opt,bool) + setPCLoop= cc.set_pcloop ,--(opt,bool) setBag= cc.set_bag7 ,--(opt,bool) setNode= cc.set_max_nodes ,--(opt,bool) free= cc.free ,--(opt/wei) @@ -275,9 +275,11 @@ return{ return 2 end,--start thinking function(P,ctrl) - if BOT.ifDead(P.AI_bot)then ins(ctrl,6)return 3 end local success,hold,move=BOT.getMove(P.AI_bot) - if success then + if success == 2 then + ins(ctrl,6) + return 3 + elseif success == 0 then if hold then ctrl[1]=8 end--Hold while move[1]do local m=rem(move,1) diff --git a/parts/player.lua b/parts/player.lua index 3e5464c8..28b257a6 100644 --- a/parts/player.lua +++ b/parts/player.lua @@ -83,7 +83,7 @@ local finesseList={ finesseList[1][3],finesseList[1][4],finesseList[7][3],finesseList[7][4]=finesseList[1][1],finesseList[1][2],finesseList[7][1],finesseList[7][2]--"2-phase" SZI finesseList[2]=finesseList[1]--S=Z finesseList[4],finesseList[5]=finesseList[3],finesseList[3]--J=L=T -local CCblockID={4,3,6,5,1,2,0} +local CCblockID={6,5,4,3,2,1,0} local freshPrepare={ none=NULL, bag=function(P) From 71130bbced15c52f7d7f282df5132150869d0594 Mon Sep 17 00:00:00 2001 From: Gompyn Date: Wed, 29 Jul 2020 15:01:38 +0800 Subject: [PATCH 2/3] make cc update field when block placement is wrong --- parts/ai.lua | 8 +++++++- parts/player.lua | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/parts/ai.lua b/parts/ai.lua index 30623400..49e673aa 100644 --- a/parts/ai.lua +++ b/parts/ai.lua @@ -275,11 +275,17 @@ return{ return 2 end,--start thinking function(P,ctrl) - local success,hold,move=BOT.getMove(P.AI_bot) + local success,dest,hold,move=BOT.getMove(P.AI_bot) if success == 2 then ins(ctrl,6) return 3 elseif success == 0 then + for i=1,#dest do + for j=1,#dest[i] do + dest[i][j] = dest[i][j] + 1 + end + end + P.AI_dest = dest if hold then ctrl[1]=8 end--Hold while move[1]do local m=rem(move,1) diff --git a/parts/player.lua b/parts/player.lua index 28b257a6..970f57e3 100644 --- a/parts/player.lua +++ b/parts/player.lua @@ -1273,6 +1273,7 @@ function player.freshLockDelay(P) end end function player.lock(P) + local dest = P.AI_dest for i=1,P.r do local y=P.curY+i-1 if not P.field[y]then P.field[y],P.visTime[y]=freeRow.get(0),freeRow.get(0)end @@ -1280,6 +1281,20 @@ function player.lock(P) if P.cur.bk[i][j]then P.field[y][P.curX+j-1]=P.cur.color P.visTime[y][P.curX+j-1]=P.showTime + local x = P.curX+j-1 + if dest then + local original_length = #dest + for k=1,original_length do + if x == dest[k][1] and y == dest[k][2] then + rem(dest, k) + break + end + end + if #dest ~= original_length - 1 then + CC_updateField(P) + dest = nil + end + end end end end From 5342d4f6d61a948f5dde97ca0067277b19c61665 Mon Sep 17 00:00:00 2001 From: Gompyn Date: Fri, 31 Jul 2020 17:19:36 +0800 Subject: [PATCH 3/3] make CC update field *after* locking --- parts/player.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parts/player.lua b/parts/player.lua index 970f57e3..2b243a07 100644 --- a/parts/player.lua +++ b/parts/player.lua @@ -1274,6 +1274,7 @@ function player.freshLockDelay(P) end function player.lock(P) local dest = P.AI_dest + local has_dest = (dest ~= nil) for i=1,P.r do local y=P.curY+i-1 if not P.field[y]then P.field[y],P.visTime[y]=freeRow.get(0),freeRow.get(0)end @@ -1291,13 +1292,15 @@ function player.lock(P) end end if #dest ~= original_length - 1 then - CC_updateField(P) dest = nil end end end end end + if has_dest and not dest then + CC_updateField(P) + end end function player.spin(P,d,ifpre) local iki=P.RS[P.cur.id]