From af61d27a4f4ead7831015ea6bbcad0b716d113f7 Mon Sep 17 00:00:00 2001 From: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Thu, 4 Jul 2024 02:09:16 +0800 Subject: [PATCH 1/6] add a new mode: spin ren --- parts/modes/spinren.lua | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 parts/modes/spinren.lua diff --git a/parts/modes/spinren.lua b/parts/modes/spinren.lua new file mode 100644 index 000000000..c8c9d35e4 --- /dev/null +++ b/parts/modes/spinren.lua @@ -0,0 +1,63 @@ +---@param RND RandomGenerator +local randomizer=function(RND) + local this=1 + return function() + -- weights to get 2:2:2:1 steady distribution + local weights={5,5,5,2} + local ret=this + weights[this]=0 + local sum=weights[1]+weights[2]+weights[3]+weights[4] + local r=RND:random(1,sum) + for i=1,4 do + r=r-weights[i] + if r<=0 then + this=i + break + end + end + return ret + end +end +local lines={ + {1,2,3,4,0,0,5,6,7,8}, + {7,6,5,0,0,0,4,3,2,1}, + {1,2,3,4,0,0,0,5,6,7}, + {7,6,5,0,0,0,0,4,3,2} +} +local function get_lines(n,f) + local ret={} + for _=1,n do + table.insert(ret,lines[f()]) + end + return ret +end + +return { + load=function() + PLY.newPlayer(1) + local our=PLY_ALIVE[1] + our.randomizer_spinren=randomizer(our.holeRND) + our:pushLineList(get_lines(20,our.randomizer_spinren)) + end, + env={ + lock=1e99, + drop=1e99, + infHold=true, + eventSet='sprintEff_40', + hook_drop=function(P) + if P.lastPiece.row==0 then + P:win('finish') + end + local up=MATH.clamp(20-P.stat.row,0,P.lastPiece.row) + P:pushLineList(get_lines(up,P.randomizer_spinren)) + end + }, + score=function(P) return {P.stat.atk/P.stat.row,P.stat.time} end, + scoreDisp=function(D) return string.format("%.3f",D[1]).." Efficiency "..STRING.time(D[2]) end, + comp=function(a,b) return a[1]>b[1] or a[1]==b[1] and a[2] Date: Fri, 5 Jul 2024 09:31:40 +0800 Subject: [PATCH 2/6] remove some bad cases; rework of the weights --- parts/modes/spinren.lua | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/parts/modes/spinren.lua b/parts/modes/spinren.lua index c8c9d35e4..10d06d9c2 100644 --- a/parts/modes/spinren.lua +++ b/parts/modes/spinren.lua @@ -1,20 +1,34 @@ ---@param RND RandomGenerator local randomizer=function(RND) - local this=1 + local ins=table.insert + local last={1} + local weights={2,2,1} + local r=RND:random(1,5) + for i=1,#weights do + r=r-weights[i] + if r<=0 then + ins(last,i+1) + break + end + end return function() - -- weights to get 2:2:2:1 steady distribution - local weights={5,5,5,2} - local ret=this - weights[this]=0 - local sum=weights[1]+weights[2]+weights[3]+weights[4] - local r=RND:random(1,sum) - for i=1,4 do - r=r-weights[i] - if r<=0 then - this=i - break - end + local ret=last[1] + local this + if ret==1 and last[2]==4 or ret==4 and last[2]==1 then + this=RND:random(1,2)+1 + elseif ret==1 then + this=5-last[2] + elseif ret==4 then + this=1 + elseif last[2]==1 then + local r=RND:random(1,5) + this=r==1 and 4 or 5-ret + elseif last[2]==4 then + this=RND:random(1,2)==1 and 1 or 5-ret + else + this=RND:random(1,5)<3 and 4 or 1 end + last={last[2],this} return ret end end From 2917051563e1f32b30f127da4af999a8ea7ee966 Mon Sep 17 00:00:00 2001 From: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:04:15 +0800 Subject: [PATCH 3/6] fix lines --- parts/modes/spinren.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parts/modes/spinren.lua b/parts/modes/spinren.lua index 10d06d9c2..2e029d0da 100644 --- a/parts/modes/spinren.lua +++ b/parts/modes/spinren.lua @@ -62,7 +62,7 @@ return { if P.lastPiece.row==0 then P:win('finish') end - local up=MATH.clamp(20-P.stat.row,0,P.lastPiece.row) + local up=MATH.clamp(20-P.stat.row+P.lastPiece.row,0,P.lastPiece.row) P:pushLineList(get_lines(up,P.randomizer_spinren)) end }, From 332631d1db6ddfd1609e7db892179f8a871ecc15 Mon Sep 17 00:00:00 2001 From: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Sat, 6 Jul 2024 12:45:20 +0800 Subject: [PATCH 4/6] add different orientation for 323 --- parts/modes/spinren.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parts/modes/spinren.lua b/parts/modes/spinren.lua index 2e029d0da..a70f69227 100644 --- a/parts/modes/spinren.lua +++ b/parts/modes/spinren.lua @@ -22,7 +22,10 @@ local randomizer=function(RND) this=1 elseif last[2]==1 then local r=RND:random(1,5) - this=r==1 and 4 or 5-ret + this= + r==1 and 4 or + r<4 and ret or + 5-ret elseif last[2]==4 then this=RND:random(1,2)==1 and 1 or 5-ret else From 39f3d2f4999c2a73749949265aee4f8684c1c7c7 Mon Sep 17 00:00:00 2001 From: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:37:00 +0800 Subject: [PATCH 5/6] harder ranking --- parts/modes/spinren.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/parts/modes/spinren.lua b/parts/modes/spinren.lua index a70f69227..60aa091e2 100644 --- a/parts/modes/spinren.lua +++ b/parts/modes/spinren.lua @@ -75,6 +75,12 @@ return { getRank=function(P) if P.stat.row<10 then return end local E=P.stat.atk/P.stat.row - return math.min(math.floor(E/2),5) + return + E>=10 and 5 or + E>=9 and 4 or + E>=8 and 3 or + E>=6 and 2 or + E>=3 and 1 or + 0 end } \ No newline at end of file From 6d9d691b1a55f26a0131401466d61a440d6b935f Mon Sep 17 00:00:00 2001 From: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Sat, 27 Jul 2024 09:03:42 +0800 Subject: [PATCH 6/6] Fix the map to sijun's mode This mode can be used as big-bang! --- parts/modes/spinren.lua | 52 +++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/parts/modes/spinren.lua b/parts/modes/spinren.lua index 60aa091e2..b0db97210 100644 --- a/parts/modes/spinren.lua +++ b/parts/modes/spinren.lua @@ -1,38 +1,28 @@ ---@param RND RandomGenerator -local randomizer=function(RND) - local ins=table.insert - local last={1} - local weights={2,2,1} - local r=RND:random(1,5) - for i=1,#weights do - r=r-weights[i] - if r<=0 then - ins(last,i+1) - break +local function randomizer(RND) + local last=RND:random(2)==1 and 1 or 4 + local function get_next() + local list={1,2,3,1,3,2} + local ret=list[last] + last=last+1 + if last>6 then last=1 end + return ret + end + local bag={} + local function fill_bag() + local weights=0 + while weights<24 do + local x=get_next() + table.insert(bag,x) + weights=weights+(x==1 and 2 or 3) end + local pos=RND:random(#bag)+1 + table.insert(bag,pos,4) + if skip==1 then skip=0 end end return function() - local ret=last[1] - local this - if ret==1 and last[2]==4 or ret==4 and last[2]==1 then - this=RND:random(1,2)+1 - elseif ret==1 then - this=5-last[2] - elseif ret==4 then - this=1 - elseif last[2]==1 then - local r=RND:random(1,5) - this= - r==1 and 4 or - r<4 and ret or - 5-ret - elseif last[2]==4 then - this=RND:random(1,2)==1 and 1 or 5-ret - else - this=RND:random(1,5)<3 and 4 or 1 - end - last={last[2],this} - return ret + if #bag==0 then fill_bag() end + return table.remove(bag,1) end end local lines={