Skip to content

Instantly share code, notes, and snippets.

@m-byte918
Last active August 14, 2023 03:26
Show Gist options
  • Save m-byte918/98e47d96102eee4dd3b166ee684d68ca to your computer and use it in GitHub Desktop.
Save m-byte918/98e47d96102eee4dd3b166ee684d68ca to your computer and use it in GitHub Desktop.
MK8DX meta score calculator
// Ordered from least -> most important
// See: https://strawpoll.com/polls/B2ZBEWz5zgJ/results
const stats = ["trc", "inv", "hdl", "wt", "acl", "spd", "mt"];
// nth triangle number - https://math.stackexchange.com/questions/593318/factorial-but-with-addition
const n = stats.length;
const statWeightScalar = 1 / ((n**2 + n) / 2);
const statWeights = { };
for (let i = 0; i < n; ++i) {
statWeights[stats[i]] = (i + 1) * statWeightScalar;
}
// Different weights for each speed/handling type, see: https://vikemk.com/posts/mk8dx-combos
// and https://docs.google.com/spreadsheets/d/1idLq3OYkEjRI0U64LCLxVY-GvdhRPgO75KZUPS4m70o/edit#gid=0
statWeights["spd"] = {
"gnd": statWeights["spd"] * 0.737,
"grv": statWeights["spd"] * 0.181,
"air": statWeights["spd"] * 0.056,
"wtr": statWeights["spd"] * 0.026,
};
statWeights["hdl"] = {
"gnd": statWeights["hdl"] * 0.737,
"grv": statWeights["hdl"] * 0.181,
"air": statWeights["hdl"] * 0.056,
"wtr": statWeights["hdl"] * 0.026,
};
function calcMetaScore([spdGnd, spdWtr, spdAir, spdGrv], acl, wt, [hdlGnd, hdlWtr, hdlAir, hdlGrv], trc, mt, inv) {
const metaScore = spdGnd * statWeights["spd"]["gnd"] +
spdWtr * statWeights["spd"]["wtr"] +
spdAir * statWeights["spd"]["air"] +
spdGrv * statWeights["spd"]["grv"] +
acl * statWeights["acl"] +
// Weight is no longer floored to the nearest whole number as of version 2.1.0.
// see https://media.discordapp.net/attachments/905144339385159783/1140484171165356093/gKbcfRh.png
wt * statWeights["wt"] +
hdlGnd * statWeights["hdl"]["gnd"] +
hdlWtr * statWeights["hdl"]["wtr"] +
hdlAir * statWeights["hdl"]["air"] +
hdlGrv * statWeights["hdl"]["grv"] +
trc * statWeights["trc"] +
mt * statWeights["mt"] +
inv * statWeights["inv"];
return metaScore.toFixed(3); // Round to the nearest thousandth
}
// Example usage - stats from https://mk8dxbuilder.com/
let score = calcMetaScore([3.25, 4.25, 4.5, 4], 4, 3, [3.75, 3.5, 4, 4.25], 3.25, 4.75, 2.25);
console.log(`luigi inkstriker: ${score}`);
score = calcMetaScore([3, 4, 4.25, 3.75], 4.25, 2.5, [3.75, 3.5, 4, 4.25], 3.75, 5, 2.25);
console.log(`yoshi inkstriker: ${score}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment