「ノート:Tournament」の版間の差分

提供: Wikiducca
移動: 案内検索
(未完成です。)
 
行10: 行10:
 
while args[i] ~= "result" do
 
while args[i] ~= "result" do
 
team[i] = args[i]
 
team[i] = args[i]
nRow[0][i] = 1
+
data[0][i] = {a = 1, b = 1}
 
i = i + 1
 
i = i + 1
 
end
 
end
行20: 行20:
 
local prev = 1
 
local prev = 1
 
local row = 0
 
local row = 0
nRow[1] = {}
+
data[1] = {}
while args[i] ~= nil do
+
while args[i] ~= nil and row == 0 do
 +
data[round][curr] = {}
 +
data[round][curr].e = data[round-1][prev].e
 +
data[round][curr].f = data[round-1][prev].f
 +
 
if args[i] == "bye" then
 
if args[i] == "bye" then
nRow[round][curr]  = nRow[round-1][prev]
 
nRow[round][curr+1] = nRow[round-1][prev+1]
 
prev = prev + 2
 
 
i = i + 1
 
i = i + 1
else
+
elseif data[round-1][prev+1] ~= nil then
if nRow[round-1][prev+2] == nil then break end
+
local prev1 = data[round-1][prev].e
local prev1 = nRow[round-1][prev+1]
+
local prev2 = data[round-1][prev].f
local prev2 = nRow[round-1][prev+2]
+
local prev3 = data[round-1][prev+1].e
 +
local prev4 = data[round-1][prev+1].f
 
local curr1
 
local curr1
if prev1 > prev2 then
+
if prev2 > prev3 then
curr1 = (prev1 + prev2 + (curr1 % 2)) / 2
+
curr1 = (prev2 + prev3 + (curr1 % 2)) / 2
 
else
 
else
curr1 = (prev1 + prev2 - (curr1 % 2)) / 2
+
curr1 = (prev2 + prev3 - (curr1 % 2)) / 2
 
end
 
end
local curr2 = (prev1 + prev2) - curr1
+
local curr2 = (prev2 + prev3) - curr1
nRow[round][curr]   = nRow[round-1][prev]  + curr1
+
data[round][curr] = {
nRow[round][curr+1] = nRow[round-1][prev+3] + curr2
+
a = prev1, b = prev2, c = prev3, d = prev4, e = curr1, f = curr2,
prev = prev + 4
+
args[i], args[i+1], args[i+2], args[i+3]
 +
}
 
i = i + 4
 
i = i + 4
 
end
 
end
row = row + nRow[round][curr] + nRow[round][curr+1]
+
 +
prev = prev + 1
 +
row = row + data[round][curr].e + data[round][curr].f
 
if row == nTeam then
 
if row == nTeam then
 
round = round + 1
 
round = round + 1
行49: 行54:
 
prev = 1
 
prev = 1
 
row = 0
 
row = 0
nRow[round] = {}
+
data[round] = {}
 
else
 
else
curr = curr + 2
+
curr = curr + 1
 
end
 
end
 
end
 
end
 
+
round = round - 1
 +
 +
 +
 +
 +
 +
 +
 +
 
return ""
 
return ""
 
end
 
end
  
 
return p
 
return p

2017年10月27日 (金) 21:05時点における版

local p = {}

function p.main(frame) local args = frame.args local team = {} local nRow = { [0] = {} } local line = {}

local i = 1 while args[i] ~= "result" do team[i] = args[i] data[0][i] = {a = 1, b = 1} i = i + 1 end local nTeam = i - 1 i = i + 1

local round = 1 local curr = 1 local prev = 1 local row = 0 data[1] = {} while args[i] ~= nil and row == 0 do data[round][curr] = {} data[round][curr].e = data[round-1][prev].e data[round][curr].f = data[round-1][prev].f

if args[i] == "bye" then i = i + 1 elseif data[round-1][prev+1] ~= nil then local prev1 = data[round-1][prev].e local prev2 = data[round-1][prev].f local prev3 = data[round-1][prev+1].e local prev4 = data[round-1][prev+1].f local curr1 if prev2 > prev3 then curr1 = (prev2 + prev3 + (curr1 % 2)) / 2 else curr1 = (prev2 + prev3 - (curr1 % 2)) / 2 end local curr2 = (prev2 + prev3) - curr1 data[round][curr] = { a = prev1, b = prev2, c = prev3, d = prev4, e = curr1, f = curr2, args[i], args[i+1], args[i+2], args[i+3] } i = i + 4 end

prev = prev + 1 row = row + data[round][curr].e + data[round][curr].f if row == nTeam then round = round + 1 curr = 1 prev = 1 row = 0 data[round] = {} else curr = curr + 1 end end round = round - 1





return "" end

return p