【珊瑚分享】怪物档次设计小工具+lua反算BP代码
本帖最后由 珊瑚 于 2024-4-12 20:15 编辑输入想要的怪物能力值反向计算boss的五维档
主要用来快速设定怪物能力值,不需要反复填写档值查看结果
因为是反向计算的,数值有一定误差,请自行手动调整
目前该工具已集成到新版珊瑚工具箱里面,等其他功能做好后再发布,先发布独立小工具
再贴一段反向计算的lua代码,可以不用以enemybase为标准生成怪物了,
设定想要的能力值lua计算BP并生成怪物即可
function gaussJordan(matrix, constants)
local n = #matrix
for i = 1, n do
-- 寻找最大的元素作为主元
local max = i
for j = i + 1, n do
if math.abs(matrix) > math.abs(matrix) then
max = j
end
end
-- 如果主元是0,则无解或者无限多解
if matrix == 0 then
--自行处理
end
-- 交换行使得绝对值最大的元素处于对角线上
matrix, matrix = matrix, matrix
constants, constants = constants, constants
-- 归一化当前行,并确保对角线元素为1
local diag = matrix
for j = 1, n do
matrix = matrix / diag
end
constants = constants / diag
-- 消除当前列的其他行
for k = 1, n do
if k ~= i then
local factor = matrix
for l = 1, n do
matrix = matrix - factor * matrix
end
constants = constants - factor * constants
end
end
end
return constants
end
-- 系数矩阵
local matrix = {
{8, 2, 3, 3, 1},
{1, 2, 2, 2, 10},
{0.1, 2, 0.2, 0.2, 0.1},
{0.1, 0.2, 2, 0.2, 0.1},
{0.1, 0.2, 0.2, 2, 0.1}
}
-- 常数向量
local constants = {30000, 5000, 1000, 500, 300}
-- 解方程组
local solutions = gaussJordan(matrix, constants)
-- 输出结果
print("a =", solutions)
print("b =", solutions)
print("c =", solutions)
print("d =", solutions)
print("e =", solutions)
页:
[1]