Change to smart scheduling
This commit is contained in:
parent
374f14ea65
commit
99c5d23c11
@ -1,9 +1,10 @@
|
||||
import {NS} from "NetscriptDefinitions";
|
||||
export async function main(ns: NS) {
|
||||
const server: string = <string>ns.args[0];
|
||||
while (true) {
|
||||
/* This code checks conditions that are not needed with smart scheduling
|
||||
const moneyThresh: number = <number>ns.args[1];
|
||||
const securityThresh: number = <number>ns.args[2];
|
||||
while (true) {
|
||||
if (ns.getServerSecurityLevel(server) > securityThresh) {
|
||||
await ns.weaken(server);
|
||||
} else if (ns.getServerMoneyAvailable(server) < moneyThresh) {
|
||||
@ -11,5 +12,13 @@ export async function main(ns: NS) {
|
||||
} else {
|
||||
await ns.hack(server);
|
||||
}
|
||||
*/
|
||||
|
||||
// Guide
|
||||
// https://darktechnomancer.github.io/#glossary-of-terms
|
||||
await ns.weaken(server);
|
||||
await ns.grow(server);
|
||||
await ns.weaken(server);
|
||||
await ns.hack(server);
|
||||
}
|
||||
}
|
@ -6,10 +6,12 @@ export async function main(ns: NS) {
|
||||
let servers: string[] = recursiveScan(ns);
|
||||
|
||||
for (const server of servers) {
|
||||
let moneyThresh = ns.getServerMaxMoney(server) * 0.75;
|
||||
let securityThresh = ns.getServerMinSecurityLevel(server) + 5;
|
||||
// Commented out code is not needed with smart scheduling
|
||||
//let moneyThresh = ns.getServerMaxMoney(server) * 0.75;
|
||||
//let securityThresh = ns.getServerMinSecurityLevel(server) + 5;
|
||||
let numThreads = ns.getServerMaxRam(server) / ns.getScriptRam("hack.js")
|
||||
numThreads = Math.floor(numThreads);
|
||||
executeScriptOnServerFromAnother(ns, server, "hack.js", numThreads, [server, moneyThresh, securityThresh])
|
||||
//executeScriptOnServerFromAnother(ns, server, "hack.js", numThreads, [server, moneyThresh, securityThresh])
|
||||
executeScriptOnServerFromAnother(ns, server, "hack.js", numThreads, [server])
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user