【省流版】复制运行以下lua代码:
local function GetMaxTearsAngleInBranch(b)
local maxTearsAngleInBranch = 0
if b <= 0 then
maxTearsAngleInBranch = 0
elseif b <= 1 then
maxTearsAngleInBranch = 90
else
maxTearsAngleInBranch = 110
end
print("maxTearsAngleInBranch = "..tostring(maxTearsAngleInBranch))
return maxTearsAngleInBranch
end
local function TearsInBranchOverflow(b)
return (b >= 8 )
end
local function GetTearsInBranch(b)
local tearsInBranch = 1
if TearsInBranchOverflow(b) then
tearsInBranch = 8
else
tearsInBranch = b + 1
end
tearsInBranch = math.min(16, tearsInBranch)
print("tearsInBranch = "..tostring(tearsInBranch))
return tearsInBranch
end
local function GetMaxBranchAngle(x, y, z)
local m = x + 2 * y + 1
local angles = 0
if m > 1 then
angles = m
end
local angleOffset = 4.34
local maxBranchAngle = angleOffset * angles
if z > 0 then
local k = 0.4
maxBranchAngle = k * maxBranchAngle
end
print("maxBranchAngle = "..tostring(maxBranchAngle))
return maxBranchAngle
end
local function TearsOverflow(branches, tearsInBranch)
return (branches * tearsInBranch > 16)
end
local function GetBranches(b, x, y, z, tearsInBranch)
local branches = 1
if TearsInBranchOverflow(b) then
branches = 2
else
local m = x + 2 * y + 1
local n
if z > 1 then
n = m + (z - 1) + 1
else
n = m + 1
end
if m > 1 or z > 0 then
branches = branches + 1 + math.floor((n - 2) / tearsInBranch)
end
if TearsOverflow(branches, tearsInBranch) then
branches = math.floor(16 / tearsInBranch)
end
end
print("branches = "..tostring(branches))
return branches
end
local function UpdateBranchesOnConjoined(branches, b, x, y, z)
if b < 1 then
if x > 0 or y > 0 or z > 0 then
branches = math.min(16, branches + 2 )
end
elseif b == 1 then
branches = math.min(16, branches + 1)
end
print("update branches on conjoined: branches = "..tostring(branches))
return branches
end
local function UpdateTearsOnConjoined(tears, b, x, y, z)
if b < 1 then
if x > 0 or y > 0 or z > 0 then
tears[#tears] = nil
tears[#tears] = nil
end
tears[#tears + 1] = {
[1] = -45,
[2] = 45
}
end
print("update tears on conjoined")
return tears
end
local function GetTears(b, x, y, z, c)
local maxTearsAngleInBranch = GetMaxTearsAngleInBranch(b)
local tearsInBranch = GetTearsInBranch(b)
local maxBranchAngle = GetMaxBranchAngle(x, y, z)
local branches = GetBranches(b, x, y, z, tearsInBranch)
if c then
branches = UpdateBranchesOnConjoined(branches, b, x, y, z)
end
local startBranchAngle = - maxBranchAngle / 2
local startTearsAngleInBranch = - maxTearsAngleInBranch / 2
local BranchAngleOffset = maxBranchAngle / (branches - 1)
local TearsAngleOffset = maxTearsAngleInBranch / (tearsInBranch - 1)
local curBranchAngle = startBranchAngle
local curTearsAngleInBranch = startTearsAngleInBranch
local tears = {}
for i = 1, branches, 1 do
tears[i] = {}
for j = 1, tearsInBranch, 1 do
tears[i][j] = curBranchAngle + curTearsAngleInBranch
curTearsAngleInBranch = curTearsAngleInBranch + TearsAngleOffset
end
curTearsAngleInBranch = startTearsAngleInBranch
curBranchAngle = curBranchAngle + BranchAngleOffset
end
if c then
tears = UpdateTearsOnConjoined(tears, b, x, y, z)
end
return tears
end
local function PrintTears(tears)
print("your tears: ")
for i = 1, #tears, 1 do
for j = 1, #tears[i], 1 do
print("["..tostring(i)..", "..tostring(j).."] = "..tostring(tears[i][j]))
end
end
end
local b = 0---巫师帽:自然数
local x = 0 --内眼:自然数
local y = 0 --变异蜘蛛:自然数
local z = 0 --完美视力:自然数
local c = false --宝宝套:true/ false
local tears = GetTears(b, x, y, z, c)
print("your collectibles: 巫师帽:"..tostring(b)
..",内眼:"..tostring(x)
..",蜘蛛:"..tostring(y)
..",眼镜:"..tostring(z)
..",宝宝套:"..tostring(c))
PrintTears(tears)
local function GetMaxTearsAngleInBranch(b)
local maxTearsAngleInBranch = 0
if b <= 0 then
maxTearsAngleInBranch = 0
elseif b <= 1 then
maxTearsAngleInBranch = 90
else
maxTearsAngleInBranch = 110
end
print("maxTearsAngleInBranch = "..tostring(maxTearsAngleInBranch))
return maxTearsAngleInBranch
end
local function TearsInBranchOverflow(b)
return (b >= 8 )
end
local function GetTearsInBranch(b)
local tearsInBranch = 1
if TearsInBranchOverflow(b) then
tearsInBranch = 8
else
tearsInBranch = b + 1
end
tearsInBranch = math.min(16, tearsInBranch)
print("tearsInBranch = "..tostring(tearsInBranch))
return tearsInBranch
end
local function GetMaxBranchAngle(x, y, z)
local m = x + 2 * y + 1
local angles = 0
if m > 1 then
angles = m
end
local angleOffset = 4.34
local maxBranchAngle = angleOffset * angles
if z > 0 then
local k = 0.4
maxBranchAngle = k * maxBranchAngle
end
print("maxBranchAngle = "..tostring(maxBranchAngle))
return maxBranchAngle
end
local function TearsOverflow(branches, tearsInBranch)
return (branches * tearsInBranch > 16)
end
local function GetBranches(b, x, y, z, tearsInBranch)
local branches = 1
if TearsInBranchOverflow(b) then
branches = 2
else
local m = x + 2 * y + 1
local n
if z > 1 then
n = m + (z - 1) + 1
else
n = m + 1
end
if m > 1 or z > 0 then
branches = branches + 1 + math.floor((n - 2) / tearsInBranch)
end
if TearsOverflow(branches, tearsInBranch) then
branches = math.floor(16 / tearsInBranch)
end
end
print("branches = "..tostring(branches))
return branches
end
local function UpdateBranchesOnConjoined(branches, b, x, y, z)
if b < 1 then
if x > 0 or y > 0 or z > 0 then
branches = math.min(16, branches + 2 )
end
elseif b == 1 then
branches = math.min(16, branches + 1)
end
print("update branches on conjoined: branches = "..tostring(branches))
return branches
end
local function UpdateTearsOnConjoined(tears, b, x, y, z)
if b < 1 then
if x > 0 or y > 0 or z > 0 then
tears[#tears] = nil
tears[#tears] = nil
end
tears[#tears + 1] = {
[1] = -45,
[2] = 45
}
end
print("update tears on conjoined")
return tears
end
local function GetTears(b, x, y, z, c)
local maxTearsAngleInBranch = GetMaxTearsAngleInBranch(b)
local tearsInBranch = GetTearsInBranch(b)
local maxBranchAngle = GetMaxBranchAngle(x, y, z)
local branches = GetBranches(b, x, y, z, tearsInBranch)
if c then
branches = UpdateBranchesOnConjoined(branches, b, x, y, z)
end
local startBranchAngle = - maxBranchAngle / 2
local startTearsAngleInBranch = - maxTearsAngleInBranch / 2
local BranchAngleOffset = maxBranchAngle / (branches - 1)
local TearsAngleOffset = maxTearsAngleInBranch / (tearsInBranch - 1)
local curBranchAngle = startBranchAngle
local curTearsAngleInBranch = startTearsAngleInBranch
local tears = {}
for i = 1, branches, 1 do
tears[i] = {}
for j = 1, tearsInBranch, 1 do
tears[i][j] = curBranchAngle + curTearsAngleInBranch
curTearsAngleInBranch = curTearsAngleInBranch + TearsAngleOffset
end
curTearsAngleInBranch = startTearsAngleInBranch
curBranchAngle = curBranchAngle + BranchAngleOffset
end
if c then
tears = UpdateTearsOnConjoined(tears, b, x, y, z)
end
return tears
end
local function PrintTears(tears)
print("your tears: ")
for i = 1, #tears, 1 do
for j = 1, #tears[i], 1 do
print("["..tostring(i)..", "..tostring(j).."] = "..tostring(tears[i][j]))
end
end
end
local b = 0---巫师帽:自然数
local x = 0 --内眼:自然数
local y = 0 --变异蜘蛛:自然数
local z = 0 --完美视力:自然数
local c = false --宝宝套:true/ false
local tears = GetTears(b, x, y, z, c)
print("your collectibles: 巫师帽:"..tostring(b)
..",内眼:"..tostring(x)
..",蜘蛛:"..tostring(y)
..",眼镜:"..tostring(z)
..",宝宝套:"..tostring(c))
PrintTears(tears)





























