Merge branch '26F-Studio:main' into VietnameseTranslation

This commit is contained in:
C6H12O6 + NaCl + H2O
2023-07-23 21:59:57 +07:00
committed by GitHub
12 changed files with 229 additions and 253 deletions

View File

@@ -830,8 +830,19 @@ do
local R=_flipList(L) local R=_flipList(L)
local F={'+0+0'} local F={'+0+0'}
local centerPos=TABLE.copy(defaultCenterPos) local centerPos=TABLE.copy(defaultCenterPos)
centerPos[6]={[0]={0,0},{1,0},{1,1},{0,1}} centerPos[6]={[0]={0,0},{1,0},{1,1},{0,1}}-- O
centerPos[7]={[0]={0,1},{2,0},{0,2},{1,0}} centerPos[7]={[0]={0,1},{2,0},{0,2},{1,0}}-- I
centerPos[14]={[0]={0,1},{1,0},{2,1},{1,2}}-- T5
centerPos[16]={[0]={1,1},{1,1},{1,1},{1,1}}-- V
centerPos[19]={[0]={0,1},{2,0},{1,2},{1,1}}-- J5
centerPos[20]={[0]={0,2},{1,0},{1,1},{2,1}}-- L5
centerPos[21]={[0]={0,2},{1,0},{1,1},{2,1}}-- R
centerPos[22]={[0]={0,1},{2,0},{1,2},{1,1}}-- Y
centerPos[23]={[0]={0,1},{2,0},{1,2},{1,1}}-- N
centerPos[24]={[0]={0,2},{1,0},{1,1},{2,1}}-- H
centerPos[27]={[0]={0,1},{0,0},{1,0},{1,1}}-- C
centerPos[28]={[0]={0,1},{0,0},{0,0},{1,0}}-- I2
ASC={ ASC={
centerTex=GC.DO{10,10, centerTex=GC.DO{10,10,
{'setLW',2}, {'setLW',2},
@@ -857,7 +868,7 @@ do
local L={'+0+0','+1+0','+0-1','+1-1','+0-2','+1-2','+2+0','+2-1','+2-2','-1+0','-1-1','+0+1','+1+1','+2+1','-1-2','-2+0','+0+2','+1+2','+2+2','-2-1','-2-2'} local L={'+0+0','+1+0','+0-1','+1-1','+0-2','+1-2','+2+0','+2-1','+2-2','-1+0','-1-1','+0+1','+1+1','+2+1','-1-2','-2+0','+0+2','+1+2','+2+2','-2-1','-2-2'}
local R=_flipList(L) local R=_flipList(L)
local F={'+0+0','-1+0','+1+0','+0-1','-1-1','+1-1','+0-2','-1-2','+1-2','-2+0','+2+0','-2-1','+2-1','-2+1','+2+1','+0+2','-1+2','+1+2'} local F={'+0+0','-1+0','+1+0','+0-1','-1-1','+1-1','+0-2','-1-2','+1-2','-2+0','+2+0','-2-1','+2-1','-2+1','+2+1','+0+2','-1+2','+1+2'}
local centerPos=TABLE.copy(defaultCenterPos) local centerPos=TABLE.copy(ASC.centerPos)
centerPos[6]={[0]={0,0},{1,0},{1,1},{0,1}} centerPos[6]={[0]={0,0},{1,0},{1,1},{0,1}}
centerPos[7]={[0]={0,1},{2,0},{0,2},{1,0}} centerPos[7]={[0]={0,1},{2,0},{0,2},{1,0}}
ASC_plus={ ASC_plus={

View File

@@ -43,8 +43,8 @@ function bot_cc:revive()
self.P:loadAI(self.data) self.P:loadAI(self.data)
end end
function bot_cc:pushNewNext(id) function bot_cc:pushNewNext(id)
self.ccBot:addNext(rem(self.bufferedNexts,1))
ins(self.bufferedNexts,id) ins(self.bufferedNexts,id)
self.ccBot:addNext(rem(self.bufferedNexts,1))
end end
function bot_cc:thread() function bot_cc:thread()
local P,keys=self.P,self.keys local P,keys=self.P,self.keys

View File

@@ -186,12 +186,12 @@ local L={
joystickR= 0xF018A, joystickR= 0xF018A,
jsLU= 0xF018B, jsLU= 0xF018B,
jsLD= 0xF018C, jsLD= 0xF018C,
jsLL= 0xF018D, jsLR= 0xF018D,
jsLR= 0xF018E, jsLL= 0xF018E,
jsRU= 0xF018F, jsRU= 0xF018F,
jsRD= 0xF0190, jsRD= 0xF0190,
jsRL= 0xF0191, jsRR= 0xF0191,
jsRR= 0xF0192, jsRL= 0xF0192,
jsLPress= 0xF0193, jsLPress= 0xF0193,
jsRPress= 0xF0194, jsRPress= 0xF0194,
dpad= 0xF0195, dpad= 0xF0195,

View File

@@ -476,7 +476,7 @@ do-- Mod data
}, },
{no=19,id="CS",name="customSeq", {no=19,id="CS",name="customSeq",
key="b",x=680,y=470,color='lB', key="b",x=680,y=470,color='lB',
list={'bag','bagES','his','hisPool','c2','rnd','mess','reverb','bagP1inf'}, list={'bag','bagES','his','hisPool','c2','bagP1inf','rnd','mess','reverb'},
func=function(P,O) P.gameEnv.sequence=O end, func=function(P,O) P.gameEnv.sequence=O end,
unranked=true, unranked=true,
}, },

View File

@@ -1,78 +1,77 @@
local ins=table.insert local ins=table.insert
local yield=coroutine.yield
return { return {
env={ env={
drop=20,lock=60, drop=20,lock=60,
sequence=function(P) sequence=function(seqRND)
for _=1,3 do P:getNext(7) end local field,stat
for _=1,3 do field,stat=yield(7) end
while true do while true do
coroutine.yield() local height=TABLE.new(0,10)
if not P.nextQueue[1] then local max=#field
local height=TABLE.new(0,10) if max>0 then
local max=#P.field -- Get heights
if max>0 then for x=1,10 do
-- Get heights local h=max
for x=1,10 do while field[h][x]==0 and h>1 do
local h=max h=h-1
while P.field[h][x]==0 and h>1 do
h=h-1
end
height[x]=h
end
else
for x=1,10 do
height[x]=0
end end
height[x]=h
end end
height[11]=999 else
for x=1,10 do
local wei={1,1,2,2,3,4} height[x]=0
local d=0
for i=1,10 do
d=d+height[i]
end end
if d<40 or P.stat.row>2*42 then-- Low field or almost win, give SZO
for _=1,4 do
ins(wei,1)
ins(wei,2)
ins(wei,6)
end
else
-- Give I when no hole
local tempDeltaHei=-999-- Height difference
for x=2,11 do
local deltaHei=height[x]-height[x-1]
if tempDeltaHei<-2 and deltaHei>2 then
break
elseif x==11 then
for _=1,3 do ins(wei,7) end
else
tempDeltaHei=deltaHei
end
end
-- Give O when no d=0/give T when no d=1
local flatCount=0-- d=0 count
local stairCount=0-- d=1 count
for x=2,10 do
local _=height[x]-height[x-1]
if _==0 then
flatCount=flatCount+1
elseif _==1 or _==-1 then
stairCount=stairCount+1
end
end
if flatCount<3 then
for _=1,3 do ins(wei,6) end
end
if stairCount<3 then
for _=1,4 do ins(wei,5) end
end
end
P:getNext(wei[P.seqRND:random(#wei)])
end end
height[11]=999
local wei={1,1,2,2,3,4}
local d=0
for i=1,10 do
d=d+height[i]
end
if d<40 or stat.row>2*42 then-- Low field or almost win, give SZO
for _=1,4 do
ins(wei,1)
ins(wei,2)
ins(wei,6)
end
else
-- Give I when no hole
local tempDeltaHei=-999-- Height difference
for x=2,11 do
local deltaHei=height[x]-height[x-1]
if tempDeltaHei<-2 and deltaHei>2 then
break
elseif x==11 then
for _=1,3 do ins(wei,7) end
else
tempDeltaHei=deltaHei
end
end
-- Give O when no d=0/give T when no d=1
local flatCount=0-- d=0 count
local stairCount=0-- d=1 count
for x=2,10 do
local _=height[x]-height[x-1]
if _==0 then
flatCount=flatCount+1
elseif _==1 or _==-1 then
stairCount=stairCount+1
end
end
if flatCount<3 then
for _=1,3 do ins(wei,6) end
end
if stairCount<3 then
for _=1,4 do ins(wei,5) end
end
end
field,stat=yield(wei[seqRND:random(#wei)])
end end
end, end,
nextCount=1,holdCount=0, trueNextCount=1,nextCount=1,holdCount=0,
ospin=false, ospin=false,
freshLimit=15, freshLimit=15,
eventSet='checkLine_100', eventSet='checkLine_100',

View File

@@ -70,6 +70,11 @@ local seqGenBanner=setmetatable({
{'fRect',70-2,5-2,4,4}, {'fRect',70-2,5-2,4,4},
{'fRect',80-1,5-1,2,2}, {'fRect',80-1,5-1,2,2},
}, },
bagP1inf=GC.DO{100,10,
{'fRect',10,4,40,2},
{'fRect',55,4,20,2},
{'fRect',80,4,10,2},
},
rnd=GC.DO{100,10, rnd=GC.DO{100,10,
{'fRect',30-3,1,6,6}, {'fRect',30-3,1,6,6},
{'fRect',70-3,1,6,6}, {'fRect',70-3,1,6,6},
@@ -91,10 +96,6 @@ local seqGenBanner=setmetatable({
fixed=GC.DO{100,10, fixed=GC.DO{100,10,
{'fRect',40,4,20,2}, {'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) },{__index=function(self,k)
self[k]=self.none self[k]=self.none
return self.none return self.none

View File

@@ -33,7 +33,7 @@ return {
bone=false, bone=false,
lockout=false, lockout=false,
fieldH=20,heightLimit=1e99, fieldH=20,heightLimit=1e99,
nextCount=6,nextStartPos=1, trueNextCount=10,nextCount=6,nextStartPos=1,
holdMode='hold',holdCount=1, holdMode='hold',holdCount=1,
infHold=false,phyHold=false, infHold=false,phyHold=false,
ospin=true,deepDrop=false, ospin=true,deepDrop=false,

View File

@@ -328,17 +328,32 @@ local function _applyGameEnv(P)-- Finish gameEnv processing
ENV.nextPos=false ENV.nextPos=false
end end
P.newNext=coroutine.wrap(getSeqGen(P)) local seqGen=coroutine.create(getSeqGen(ENV.sequence))
P:newNext(P.gameEnv.seqData) local seqCalled=false
if ENV.noInitSZO then local initSZOcount=0
for _=1,5 do function P:newNext()
local C=P.nextQueue[1] local status,piece
if C and (C.id==1 or C.id==2 or C.id==6) then if seqCalled then
table.remove(P.nextQueue,1) status,piece=coroutine.resume(seqGen,P.field,P.stat)
else else
break status,piece=coroutine.resume(seqGen,P.seqRND,P.gameEnv.seqData)
end seqCalled=true
end end
if status and piece then
if ENV.noInitSZO and initSZOcount<5 then
initSZOcount=initSZOcount+1
if piece==1 or piece==2 or piece==6 then
return self:newNext()
else
initSZOcount=5
end
end
P:getNext(piece)
elseif not status then
assert(piece=='cannot resume dead coroutine')
end
end
for _=1,ENV.trueNextCount do
P:newNext() P:newNext()
end end

View File

@@ -613,7 +613,10 @@ do-- function Player:dropPosition(x,y,size)
vy=vy+.0626 vy=vy+.0626
self:setPosition(x,y,size) self:setPosition(x,y,size)
if y>2600 then if y>2600 then
table.remove(PLAYERS,TABLE.find(PLAYERS,self)) local index=TABLE.find(PLAYERS,self)
if index then
table.remove(PLAYERS,index)
end
return true return true
end end
end end
@@ -1433,7 +1436,7 @@ function Player:popNext(ifhold)-- Pop nextQueue to hand
if self.nextQueue[1] then if self.nextQueue[1] then
self.cur=rem(self.nextQueue,1) self.cur=rem(self.nextQueue,1)
self.newNext() self:newNext()
self.pieceCount=self.pieceCount+1 self.pieceCount=self.pieceCount+1
local pressing=self.keyPressing local pressing=self.keyPressing

View File

@@ -2,25 +2,20 @@ local ins,rem=table.insert,table.remove
local yield=coroutine.yield local yield=coroutine.yield
local seqGenerators={ local seqGenerators={
none=function() while true do yield() end end, none=function() end,
bag=function(P,seq0) bag=function(rndGen,seq0)
local rndGen=P.seqRND
local len=#seq0 local len=#seq0
local bag={} local bag={}
while true do while true do
while #P.nextQueue<10 do if #bag==0 then
if #bag==0 then for i=1,len do
for i=1,len do bag[i]=seq0[len-i+1]
bag[i]=seq0[len-i+1]
end
end end
P:getNext(rem(bag,rndGen:random(#bag)))
end end
yield() yield(rem(bag,rndGen:random(#bag)))
end end
end, end,
bagES=function(P,seq0) bagES=function(rndGen,seq0)
local rndGen=P.seqRND
local len=#seq0 local len=#seq0
local bag=TABLE.shift(seq0) local bag=TABLE.shift(seq0)
do-- Get a good first-bag do-- Get a good first-bag
@@ -40,52 +35,44 @@ local seqGenerators={
end end
end end
-- Finish -- Finish
for i=1,len do P:getNext(bag[i]) end for i=1,len do yield(bag[i]) end
end end
bag={} bag={}
while true do while true do
while #P.nextQueue<10 do if #bag==0 then
if #bag==0 then for i=1,len do
for i=1,len do bag[i]=seq0[len-i+1]
bag[i]=seq0[len-i+1]
end
end end
P:getNext(rem(bag,rndGen:random(#bag)))
end end
yield() yield(rem(bag,rndGen:random(#bag)))
end end
end, end,
his=function(P,seq0) his=function(rndGen,seq0)
local rndGen=P.seqRND
local len=#seq0 local len=#seq0
local hisLen=math.ceil(len*.5) local hisLen=math.ceil(len*.5)
local history=TABLE.new(0,hisLen) local history=TABLE.new(0,hisLen)
while true do while true do
while #P.nextQueue<10 do local r
local r for _=1,hisLen do-- Reroll up to [hisLen] times
for _=1,hisLen do-- Reroll up to [hisLen] times r=rndGen:random(len)
r=rndGen:random(len) local rollAgain
local rollAgain for i=1,hisLen do
for i=1,hisLen do if r==history[i] then
if r==history[i] then rollAgain=true
rollAgain=true break-- goto CONTINUE_rollAgain
break-- goto CONTINUE_rollAgain
end
end end
if not rollAgain then break end
-- ::CONTINUE_rollAgain::
end end
if history[1]~=0 then if not rollAgain then break end
P:getNext(seq0[r]) -- ::CONTINUE_rollAgain::
end
rem(history,1)
ins(history,r)
end end
yield() if history[1]~=0 then
yield(seq0[r])
end
rem(history,1)
ins(history,r)
end end
end, end,
hisPool=function(P,seq0) hisPool=function(rndGen,seq0)
local rndGen=P.seqRND
local len=#seq0 local len=#seq0
local hisLen=math.ceil(len*.5) local hisLen=math.ceil(len*.5)
local history=TABLE.new(0,hisLen)-- Indexes of mino-index local history=TABLE.new(0,hisLen)-- Indexes of mino-index
@@ -126,151 +113,116 @@ local seqGenerators={
end end
while true do while true do
while #P.nextQueue<10 do -- print"======================"
-- print"======================" -- Pick a mino from pool
-- Pick a mino from pool local tryTime=0
local tryTime=0 local r
local r repeat-- ::REPEAT_pickAgain::
repeat-- ::REPEAT_pickAgain:: local pickAgain
local pickAgain r=_poolPick()-- Random mino-index in pool
r=_poolPick()-- Random mino-index in pool for i=1,len do
for i=1,len do if r==history[i] then
if r==history[i] then tryTime=tryTime+1
tryTime=tryTime+1 if tryTime<hisLen then
if tryTime<hisLen then pickAgain=true
pickAgain=true break-- goto REPEAT_pickAgain
break-- goto REPEAT_pickAgain
end
end end
end end
if not pickAgain then break end
until true
-- Give mino to player & update history
if history[1]~=0 then
P:getNext(seq0[r])
end end
rem(history,1) if not pickAgain then break end
ins(history,r) until true
-- print("Player GET: "..r)
-- print("History: "..table.concat(history,",")) -- Give mino to player & update history
-- local L=TABLE.new("",len) if history[1]~=0 then
-- for _,v in next,pool do L[v]=L[v].."+" end yield(seq0[r])
-- for i=1,#L do print(i,droughtTimes[i],L[i]) end
end end
yield() rem(history,1)
ins(history,r)
-- print("Player GET: "..r)
-- print("History: "..table.concat(history,","))
-- local L=TABLE.new("",len)
-- for _,v in next,pool do L[v]=L[v].."+" end
-- for i=1,#L do print(i,droughtTimes[i],L[i]) end
end end
end, end,
c2=function(P,seq0) c2=function(rndGen,seq0)
local rndGen=P.seqRND
local len=#seq0 local len=#seq0
local weight=TABLE.new(0,len) local weight=TABLE.new(0,len)
while true do while true do
while #P.nextQueue<10 do local maxK=1
local maxK=1 for i=1,len do
for i=1,len do weight[i]=weight[i]*.5+rndGen:random()
weight[i]=weight[i]*.5+rndGen:random() if weight[i]>weight[maxK] then
if weight[i]>weight[maxK] then maxK=i
maxK=i
end
end end
weight[maxK]=weight[maxK]/3.5
P:getNext(seq0[maxK])
end end
yield() weight[maxK]=weight[maxK]/3.5
yield(seq0[maxK])
end end
end, end,
rnd=function(P,seq0) rnd=function(rndGen,seq0)
if #seq0==1 then if #seq0==1 then
local i=seq0[1] local i=seq0[1]
while true do while true do
while #P.nextQueue<10 do P:getNext(i) end yield(i)
yield()
end end
else else
local rndGen=P.seqRND
local len=#seq0 local len=#seq0
local last=0 local last=0
while true do while true do
while #P.nextQueue<10 do local r=rndGen:random(len-1)
local r=rndGen:random(len-1) if r>=last then
if r>=last then r=r+1
r=r+1
end
P:getNext(seq0[r])
last=r
end end
yield() yield(seq0[r])
last=r
end end
end end
end, end,
mess=function(P,seq0) mess=function(rndGen,seq0)
local rndGen=P.seqRND
while true do while true do
while #P.nextQueue<10 do yield(seq0[rndGen:random(#seq0)])
P:getNext(seq0[rndGen:random(#seq0)])
end
yield()
end end
end, end,
reverb=function(P,seq0) reverb=function(rndGen,seq0)
local rndGen=P.seqRND
local bufferSeq,bag={},{} local bufferSeq,bag={},{}
while true do while true do
while #P.nextQueue<10 do if #bag==0 then
if #bag==0 then for i=1,#seq0 do bufferSeq[i]=seq0[i] end
for i=1,#seq0 do bufferSeq[i]=seq0[i] end repeat
local r=rem(bufferSeq,rndGen:random(#bag))
local p=1
repeat repeat
local r=rem(bufferSeq,rndGen:random(#bag)) ins(bag,r)
local p=1 p=p-.15-rndGen:random()
repeat until p<0
ins(bag,r) until #bufferSeq==0
p=p-.15-rndGen:random() for i=1,#bag do
until p<0 bufferSeq[i]=bag[i]
until #bufferSeq==0
for i=1,#bag do
bufferSeq[i]=bag[i]
end
end end
P:getNext(rem(bag,rndGen:random(#bag)))
end end
yield() yield(rem(bag,rndGen:random(#bag)))
end end
end, end,
loop=function(P,seq0) loop=function(rndGen,seq0)
local len=#seq0 local len=#seq0
local bag={} local bag={}
while true do while true do
while #P.nextQueue<10 do if #bag==0 then
if #bag==0 then for i=1,len do
for i=1,len do bag[i]=seq0[len-i+1]
bag[i]=seq0[len-i+1]
end
end end
P:getNext(rem(bag))
end end
yield() yield(rem(bag))
end end
end, end,
fixed=function(P,seq0) fixed=function(rndGen,seq0)
local seq={}
for i=#seq0,1,-1 do for i=#seq0,1,-1 do
ins(seq,seq0[i]) yield(seq0[i])
end
while true do
while #P.nextQueue<10 do
if seq[1] then
P:getNext(rem(seq))
else
break
end
end
yield()
end end
end, end,
bagP1inf=function(P,seq0) bagP1inf=function(rndGen,seq0)
local rndGen=P.seqRND
local len=#seq0 local len=#seq0
local function new() local function new()
local res={} local res={}
@@ -331,24 +283,20 @@ local seqGenerators={
end end
local dist=new() local dist=new()
while true do while true do
while #P.nextQueue<10 do local sum,mydist=dist.next_dist()
local sum,mydist=dist.next_dist() local r=rndGen:random(sum)
local r=rndGen:random(sum) for i=1,len do
for i=1,len do r=r-mydist[i]
r=r-mydist[i] if r<=0 then
if r<=0 then yield(seq0[i])
P:getNext(seq0[i]) dist.update(i)
dist.update(i) break
break
end
end end
end end
yield()
end end
end, end,
} }
return function(P)-- Return a piece-generating function for player P return function(s)-- Return a piece-generating function for player P
local s=P.gameEnv.sequence
if type(s)=='function' then if type(s)=='function' then
return s return s
elseif type(s)=='string' and seqGenerators[s] then elseif type(s)=='string' and seqGenerators[s] then
@@ -359,7 +307,6 @@ return function(P)-- Return a piece-generating function for player P
"No sequence mode called "..s or "No sequence mode called "..s or
"Wrong sequence generator" "Wrong sequence generator"
) )
P.gameEnv.sequence='bag'
return seqGenerators.bag return seqGenerators.bag
end end
end end

View File

@@ -174,7 +174,7 @@ scene.widgetList={
WIDGET.newText{name='subTitle',x=530,y=50,lim=170,font=35,align='L',color='H'}, 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', WIDGET.newSelector{name='sequence',x=1080,y=60,w=200,color='Y',
list={'bag','bagES','his','hisPool','c2','rnd','mess','reverb','loop','fixed','bagP1inf'}, list={'bag','bagES','his','hisPool','c2','bagP1inf','rnd','mess','reverb','loop','fixed'},
disp=CUSval('sequence'),code=CUSsto('sequence') disp=CUSval('sequence'),code=CUSsto('sequence')
}, },

View File

@@ -165,6 +165,9 @@ function scene.update(dt)
end end
end end
local function listStencil()
GC.rectangle('fill',20,180,280,526)
end
function scene.draw() function scene.draw()
gc.setColor(COLOR.dX) gc.setColor(COLOR.dX)
gc.rectangle('fill',300,180,958,526,5) gc.rectangle('fill',300,180,958,526,5)
@@ -189,19 +192,16 @@ function scene.draw()
gc.setColor(1,1,1,.4+.05*sin(TIME()*12.6)) gc.setColor(1,1,1,.4+.05*sin(TIME()*12.6))
gc.rectangle('fill',20,143+35*(selected-scrollPos),280,35) gc.rectangle('fill',20,143+35*(selected-scrollPos),280,35)
GC.stencil(listStencil)
GC.setStencilTest('equal',1)
setFont(30) setFont(30)
for i=1,min(#list,15) do for i=1,min(#list,15) do
local y=142+35*i local y=142+35*i
i=i+scrollPos i=i+scrollPos
local item=list[i] local item=list[i]
gc.setColor(COLOR.D) GC.shadedPrint(item.title,30,y,'left',1,COLOR.D,typeColor[item.type])
gc.print(item.title,29,y-1)
gc.print(item.title,29,y+1)
gc.print(item.title,31,y-1)
gc.print(item.title,31,y+1)
gc.setColor(typeColor[item.type])
gc.print(item.title,30,y)
end end
GC.setStencilTest()
if searchWait>0 then if searchWait>0 then
local r=TIME()*2 local r=TIME()*2