Skip to content

Instantly share code, notes, and snippets.

@Grimy
Created December 19, 2016 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Grimy/a0337bad2759af8bc8a1a0a4c4344ad1 to your computer and use it in GitHub Desktop.
Save Grimy/a0337bad2759af8bc8a1a0a4c4344ad1 to your computer and use it in GitHub Desktop.
// Amount of Helium awarded at the end of the given zone.
function zone_helium(z, lead) {
let level = (z - 19) * 1.35;
let base = z >= 151 ? 10 : z >= 59 ? 5 : 1;
let reward = Math.round(base * Math.pow(1.23, Math.sqrt(level))) + Math.round(base * level);
reward *= lead && (z % 2 == 1) ? 2 : 1;
return reward * Math.pow(1.005, z);
}
// Total helium from a run up to the given zone
function run_helium(z, lead) {
let corruption_start = lead ? 151 : 60;
let value = lead ? 0.15 : 0.075;
let result = 0;
for (let i = 21; i <= z; ++i) {
let corrupt = Math.floor((i - corruption_start) / 3);
corrupt = corrupt < 0 ? 0 : Math.min(corrupt + 2, 80);
result += zone_helium(i, lead) * (1 + corrupt * value);
}
return result;
}
console.log('Lead: ', 2.5 * run_helium(180, true) + run_helium(190, true));
console.log('Corrupted: ', 2 * run_helium(190, false));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment