Skip to content

Instantly share code, notes, and snippets.

@Hidden50
Created January 10, 2021 19:34
Show Gist options
  • Save Hidden50/297c03cf1c08982d5c5f727fd282d3a4 to your computer and use it in GitHub Desktop.
Save Hidden50/297c03cf1c08982d5c5f727fd282d3a4 to your computer and use it in GitHub Desktop.
[...(function* () {
for (const pokemon of app.pokeData) {
let bestChance = 0;
for (const dish in pokemon.recipeWeights) {
for (const quality in pokemon.recipeWeights[dish]) {
const weight = pokemon.recipeWeights[dish][quality];
const chance = weight / app.recipeWeightSums[dish][quality];
if (!app.recipeTable[dish][quality].length) {
continue; // impossible: no recipe results in this dish/quality combination
}
if (chance > bestChance) {
bestChance = chance;
}
}
}
if (bestChance !== 0) {
yield [pokemon.name, bestChance];
}
}
})()]
.sort( ([, left], [, right]) => right - left )
.map( ([pokemon, chance]) => [pokemon, (100 * chance).toFixed(2) + "%"] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment