Skip to content

Instantly share code, notes, and snippets.

@stalefishies
stalefishies / batch.js
Created August 22, 2022 16:02
Periodic batcher benchmarking script
// Solve for number of growth threads required to get from money_lo to money_hi
function solveGrow(base, money_lo, money_hi) {
if (money_lo >= money_hi) { return 0; }
let threads = 1000;
let prev = threads;
for (let i = 0; i < 30; ++i) {
let factor = money_hi / Math.min(money_lo + threads, money_hi - 1);
threads = Math.log(factor) / Math.log(base);
if (Math.ceil(threads) == Math.ceil(prev)) { break; }
@stalefishies
stalefishies / production.js
Last active May 8, 2022 22:34
Bitburner corp material production multiplier calculator
const names = ["Hardware", "Robots", "AI Cores", "Real Estate"];
const size = [0.06, 0.5, 0.1, 0.005];
const permutations = [
[1, 1, 1, 1],
[0, 1, 1, 1],
[1, 0, 1, 1],
[1, 1, 0, 1],
[1, 1, 1, 0],
[0, 0, 1, 1],
@stalefishies
stalefishies / batch.js
Created March 3, 2022 14:40
Bitburner periodic batch manager
/** @arg {NS} ns **/
export async function main(ns) {
ns.disableLog("ALL");
const scripts = ["/bin/hack.js", "/bin/weak.js", "/bin/grow.js", "/bin/weak.js"];
const killAllScripts = function(ns, pids) {
for (let index = 0; index < pids.length; ++index) {
for (let i = 0; i < 4; ++i) { ns.kill(pids[index][i]); }
}
}