整 理 代 码
(应该没有改到字符串里面的东西吧…)起码不直接影响运行
This commit is contained in:
@@ -2,7 +2,7 @@ local ins,rem=table.insert,table.remove
|
||||
local yield=coroutine.yield
|
||||
|
||||
local seqGenerators={
|
||||
none=function()while true do yield()end end,
|
||||
none=function() while true do yield() end end,
|
||||
bag=function(P,seq0)
|
||||
local rndGen=P.seqRND
|
||||
local len=#seq0
|
||||
@@ -25,7 +25,7 @@ local seqGenerators={
|
||||
local bag=TABLE.shift(seq0)
|
||||
do--Get a good first-bag
|
||||
--Shuffle
|
||||
for i=1,len-1 do ins(bag,rem(bag,rndGen:random(len-i+1)))end
|
||||
for i=1,len-1 do ins(bag,rem(bag,rndGen:random(len-i+1))) end
|
||||
--Skip Uncomfortable minoes
|
||||
for _=1,len-1 do
|
||||
if
|
||||
@@ -40,7 +40,7 @@ local seqGenerators={
|
||||
end
|
||||
end
|
||||
--Finish
|
||||
for i=1,len do P:getNext(bag[i])end
|
||||
for i=1,len do P:getNext(bag[i]) end
|
||||
end
|
||||
bag={}
|
||||
while true do
|
||||
@@ -66,7 +66,7 @@ local seqGenerators={
|
||||
for _=1,hisLen do--Reroll up to [hisLen] times
|
||||
r=rndGen:random(len)
|
||||
for i=1,hisLen do
|
||||
if r==history[i]then
|
||||
if r==history[i] then
|
||||
goto CONTINUE_rollAgain
|
||||
end
|
||||
end
|
||||
@@ -90,7 +90,7 @@ local seqGenerators={
|
||||
|
||||
local poolLen=5*len
|
||||
local droughtTimes=TABLE.new(len,len)--Drought times of seq0
|
||||
local pool={}for i=1,len do for _=1,5 do ins(pool,i)end end--5 times indexes of seq0
|
||||
local pool={} for i=1,len do for _=1,5 do ins(pool,i) end end--5 times indexes of seq0
|
||||
local function _poolPick()
|
||||
local r=rndGen:random(poolLen)
|
||||
local res=pool[r]
|
||||
@@ -131,7 +131,7 @@ local seqGenerators={
|
||||
::REPEAT_pickAgain::
|
||||
local r=_poolPick()--Random mino-index in pool
|
||||
for i=1,len do
|
||||
if r==history[i]then
|
||||
if r==history[i] then
|
||||
tryTime=tryTime+1
|
||||
if tryTime<hisLen then
|
||||
goto REPEAT_pickAgain
|
||||
@@ -148,8 +148,8 @@ local seqGenerators={
|
||||
-- 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
|
||||
-- for _,v in next,pool do L[v]=L[v].."+" end
|
||||
-- for i=1,#L do print(i,droughtTimes[i],L[i]) end
|
||||
end
|
||||
yield()
|
||||
end
|
||||
@@ -164,7 +164,7 @@ local seqGenerators={
|
||||
local maxK=1
|
||||
for i=1,len do
|
||||
weight[i]=weight[i]*.5+rndGen:random()
|
||||
if weight[i]>weight[maxK]then
|
||||
if weight[i]>weight[maxK] then
|
||||
maxK=i
|
||||
end
|
||||
end
|
||||
@@ -178,7 +178,7 @@ local seqGenerators={
|
||||
if #seq0==1 then
|
||||
local i=seq0[1]
|
||||
while true do
|
||||
while #P.nextQueue<10 do P:getNext(i)end
|
||||
while #P.nextQueue<10 do P:getNext(i) end
|
||||
yield()
|
||||
end
|
||||
else
|
||||
@@ -213,7 +213,7 @@ local seqGenerators={
|
||||
while true do
|
||||
while #P.nextQueue<10 do
|
||||
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
|
||||
@@ -253,7 +253,7 @@ local seqGenerators={
|
||||
end
|
||||
while true do
|
||||
while #P.nextQueue<10 do
|
||||
if seq[1]then
|
||||
if seq[1] then
|
||||
P:getNext(rem(seq))
|
||||
else
|
||||
break
|
||||
@@ -265,13 +265,13 @@ local seqGenerators={
|
||||
}
|
||||
return function(P)--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
|
||||
elseif type(s)=='string'and seqGenerators[s]then
|
||||
elseif type(s)=='string' and seqGenerators[s] then
|
||||
return seqGenerators[s]
|
||||
else
|
||||
MES.new('warn',
|
||||
type(s)=='string'and
|
||||
type(s)=='string' and
|
||||
"No sequence mode called "..s or
|
||||
"Wrong sequence generator"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user