diff --git a/parts/gameTables.lua b/parts/gameTables.lua index cee2bc225..159b9a9c5 100644 --- a/parts/gameTables.lua +++ b/parts/gameTables.lua @@ -476,7 +476,7 @@ do-- Mod data }, {no=19,id="CS",name="customSeq", key="b",x=680,y=470,color='lB', - list={'bag','bagES','his','hisPool','c2','rnd','mess','reverb'}, + list={'bag','bagES','his','hisPool','c2','rnd','mess','reverb','bagP1inf'}, func=function(P,O) P.gameEnv.sequence=O end, unranked=true, }, diff --git a/parts/player/draw.lua b/parts/player/draw.lua index 510331454..37a6f5c35 100644 --- a/parts/player/draw.lua +++ b/parts/player/draw.lua @@ -91,6 +91,10 @@ local seqGenBanner=setmetatable({ fixed=GC.DO{100,10, {'fRect',40,4,20,2}, }, + --TODO: add new banner for bagP1inf + bagP1inf=GC.DO{100,10, + {'fRect',40,4,20,2}, + }, },{__index=function(self,k) self[k]=self.none return self.none diff --git a/parts/player/seqGenerators.lua b/parts/player/seqGenerators.lua index 0de68d8fd..c6a8832f4 100644 --- a/parts/player/seqGenerators.lua +++ b/parts/player/seqGenerators.lua @@ -269,6 +269,83 @@ local seqGenerators={ yield() end end, + bagP1inf=function(P,seq0) + local rndGen=P.seqRND + local len=#seq0 + local function new() + local res={} + local higher=nil + local higher_dist={} + for i=1,len do + higher_dist[i]=1 + end + local remaining=len+1 + local unknown={} + local extra=-1 + local function init() + for i=1,len do + unknown[i]=1 + end + remaining=len+1 + extra=-1 + end + init() + function res.next_dist() + if extra>=0 then + return remaining,unknown + end + local temp={} + local temp_sum=0 + for i=1,len do + local item=higher_dist[i]*(2-unknown[i]) + temp[i]=item + temp_sum=temp_sum+item + end + local sum=0 + for i=1,len do + temp[i]=temp[i]+temp_sum*unknown[i] + sum=sum+temp[i] + end + return sum,temp + end + function res.update(i) + if unknown[i]==0 then + assert(extra<0,"extra should be -1") + extra=i + else + unknown[i]=0 + end + remaining=remaining-1 + if remaining>0 then + return + end + if higher==nil then + higher=new() + end + higher.update(extra) + local _ + _,higher_dist=higher.next_dist() + init() + end + return res + end + local dist=new() + while true do + while #P.nextQueue<10 do + local sum,mydist=dist.next_dist() + local r=rndGen:random(sum) + for i=1,len do + r=r-mydist[i] + if r<=0 then + P:getNext(seq0[i]) + dist.update(i) + break + end + end + end + yield() + end + end, } return function(P)-- Return a piece-generating function for player P local s=P.gameEnv.sequence diff --git a/parts/scenes/custom_sequence.lua b/parts/scenes/custom_sequence.lua index b9e316150..63ca39c6f 100644 --- a/parts/scenes/custom_sequence.lua +++ b/parts/scenes/custom_sequence.lua @@ -174,7 +174,7 @@ scene.widgetList={ WIDGET.newText{name='subTitle',x=530,y=50,lim=170,font=35,align='L',color='H'}, WIDGET.newSelector{name='sequence',x=1080,y=60,w=200,color='Y', - list={'bag','bagES','his','hisPool','c2','rnd','mess','reverb','loop','fixed'}, + list={'bag','bagES','his','hisPool','c2','rnd','mess','reverb','loop','fixed','bagP1inf'}, disp=CUSval('sequence'),code=CUSsto('sequence') },