Files
The_Bitburner_Scripts/Mizzajl/home/testdistribute.js
2024-10-13 13:35:50 +02:00

59 lines
1.5 KiB
JavaScript

/** @param {NS} ns */
export async function main(ns) {
ns.tail();
const sScript = ns.args[0]; // script
const nThreads = ns.args[1]; // threads
const sTarget = ns.args[2]; // target server
const bRepeat = ns.args[3]; // should this script loop
const nMsecDelay = ns.args[4]; // MsecDelay
const sWeakenScript = "RMweaken.js";
const sGrowScript = "RMgrow.js";
const sHackScript = "RMhack.js";
const sListName = "serverList.txt";
const sWorkerList = "WorkerList.txt";
if (!ns.fileExists(sListName, "home")) { ns.print(`ERROR ${sListName} does not exist.`); return false; };
let sServerList = JSON.parse(ns.read(sListName));
ns.print(sScript);
ns.print(nThreads);
ns.print(sTarget);
const nScriptSize = ns.getScriptRam(sScript, "home");
const nTotalSize = nScriptSize * nThreads;
ns.print("nScriptSize = " + nScriptSize);
ns.print("nTotalSize = " + nTotalSize);
// get sorted list of most cores servers
// get total free RAM per number of cores
// calculate effect of cores on each server with cores > 1
// update nThreads
// run weaken/grow on core servers until cores = 1
// get sorted list of biggest RAM servers
// get total free RAM on core 1 servers
// run remaining weaken/grow
// run hack untill RAM on cores 1 servers run out
// run remaining hacks on smallest to biggest core servers
/*
for (i = 0; ; i++) {
let sHost = "";
ns.exec(sScript, sHost, nThreads, sTarget, bRepeat, nMsecDelay);
}
*/
}