-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修改气泡序列名称 添加更多气泡序列类型
- Loading branch information
Showing
2 changed files
with
100 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,65 @@ | ||
local ins,rem=table.insert,table.remove | ||
|
||
-- Fill list when empty, with source | ||
---@return boolean #True when filled | ||
local function supply(list,src,rep) | ||
if not list[1] then | ||
for _=1,rep or 1 do | ||
TABLE.connect(list,src) | ||
end | ||
return true | ||
end | ||
return false | ||
end | ||
|
||
---@type Techmino.Mech.puyo | ||
local sequence={} | ||
|
||
function sequence.none() | ||
while true do coroutine.yield() end | ||
---@param P Techmino.Player.puyo | ||
---@param d table cached data of generator | ||
---@param init boolean true if this is the first initializating call | ||
---@diagnostic disable-next-line | ||
function sequence.none(P,d,init) | ||
end | ||
|
||
function sequence.double3color(P) | ||
local l={} | ||
while true do | ||
if not l[1] then for i=1,3 do for j=1,3 do ins(l,{{i},{j}}) end end end | ||
coroutine.yield(rem(l,P:random(#l))) | ||
end | ||
end | ||
-------------------------------------------------------------- | ||
-- Twin | ||
|
||
function sequence.double4color(P) | ||
local l={} | ||
while true do | ||
if not l[1] then for i=1,4 do for j=1,4 do ins(l,{{i},{j}}) end end end | ||
coroutine.yield(rem(l,P:random(#l))) | ||
end | ||
-- Simply all permutations | ||
local TwinSet={} | ||
for i=1,8 do | ||
TwinSet[i]={} | ||
for x=1,i do for y=1,i do | ||
ins(TwinSet[i],{{x},{y}}) | ||
end end | ||
end | ||
|
||
function sequence.double5color(P) | ||
local l={} | ||
while true do | ||
if not l[1] then for i=1,5 do for j=1,5 do ins(l,{{i},{j}}) end end end | ||
coroutine.yield(rem(l,P:random(#l))) | ||
for _,bagCount in next,{2,4,8} do for colors=3,8 do | ||
sequence['twin_'..bagCount..'S'..colors..'C']=function(P,d,init) | ||
if init then d.bag={} return end | ||
supply(d.bag,TwinSet[colors],bagCount) | ||
return rem(d.bag,P:random(#d.bag)) | ||
end | ||
end end | ||
|
||
-- No repeat in one set | ||
local NRTwinSet={} | ||
for i=1,8 do | ||
NRTwinSet[i]={} | ||
for x=1,i do for y=1,x do | ||
ins(NRTwinSet[i],{{x},{y}}) | ||
end end | ||
end | ||
for _,bagCount in next,{2,4,8} do for colors=3,8 do | ||
sequence['twin_'..bagCount..'S'..colors..'NRC']=function(P,d,init) | ||
if init then d.bag={} return end | ||
supply(d.bag,NRTwinSet[colors],bagCount) | ||
return rem(d.bag,P:random(#d.bag)) | ||
end | ||
end end | ||
|
||
-------------------------------------------------------------- | ||
-- Multi | ||
|
||
-- TODO | ||
|
||
return sequence |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters