「ノート:Tournament」の版間の差分
(未完成です。) |
|||
行10: | 行10: | ||
while args[i] ~= "result" do | while args[i] ~= "result" do | ||
team[i] = args[i] | team[i] = args[i] | ||
− | + | 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 | ||
− | + | 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 | ||
− | |||
− | |||
− | |||
i = i + 1 | i = i + 1 | ||
− | + | elseif data[round-1][prev+1] ~= nil then | |
− | + | local prev1 = data[round-1][prev].e | |
− | local prev1 = | + | local prev2 = data[round-1][prev].f |
− | local | + | local prev3 = data[round-1][prev+1].e |
+ | local prev4 = data[round-1][prev+1].f | ||
local curr1 | local curr1 | ||
− | if | + | if prev2 > prev3 then |
− | curr1 = ( | + | curr1 = (prev2 + prev3 + (curr1 % 2)) / 2 |
else | else | ||
− | curr1 = ( | + | curr1 = (prev2 + prev3 - (curr1 % 2)) / 2 |
end | end | ||
− | local curr2 = ( | + | 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 | i = i + 4 | ||
end | end | ||
− | row = row + | + | |
+ | 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 | ||
− | + | data[round] = {} | |
else | else | ||
− | curr = curr + | + | 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