auto hack improved grow
This commit is contained in:
+2
-29
@@ -1,18 +1,15 @@
|
||||
/** @param {import(".").NS } ns */
|
||||
|
||||
export async function main(ns) {
|
||||
ns.disableLog('ALL');
|
||||
|
||||
const nodeCostThreshold = ns.args.length > 0 ? ns.args[0] : 0.2;
|
||||
const upgradeCostThreshold = ns.args.length > 1 ? ns.args[1] : 0.1;
|
||||
const upgradeCount = ns.args.length > 2 ? ns.args[2] : 1;
|
||||
const helperBuyThreshold = ns.args.length > 3 ? ns.args[3] : 0.2;
|
||||
const nodeCap = 24;
|
||||
const levelCap = 200;
|
||||
const ramCap = 64;
|
||||
const coreCap = 16;
|
||||
const serverRAM = 32;
|
||||
ns.tprint(`Bot started {nodeCostThreshold: ${nodeCostThreshold}, upgradeCostThreshold: ${upgradeCostThreshold}, upgradeCount: ${upgradeCount}}`);
|
||||
// ns.tprint(`Bot started {nodeCostThreshold: ${nodeCostThreshold}, upgradeCostThreshold: ${upgradeCostThreshold}, upgradeCount: ${upgradeCount}}`);
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +22,7 @@ export async function main(ns) {
|
||||
if (nodeCount < nodeCap && nodePurchaseCost / Math.abs(currentMoney) < nodeCostThreshold) {
|
||||
ns.hacknet.purchaseNode();
|
||||
currentMoney = ns.getServerMoneyAvailable("home");
|
||||
++nodeCount;
|
||||
nodeCount = ns.hacknet.numNodes();
|
||||
}
|
||||
|
||||
for (let index = 0; index < nodeCount; ++index) {
|
||||
@@ -47,30 +44,6 @@ export async function main(ns) {
|
||||
}
|
||||
}
|
||||
|
||||
let serverCost = ns.getPurchasedServerCost(serverRAM);
|
||||
|
||||
if (serverCost < currentMoney * helperBuyThreshold) {
|
||||
let newServer = ns.purchaseServer('home', serverRAM);
|
||||
if (newServer != '') {
|
||||
ns.tprint(`Bought a server`);
|
||||
ns.scp('grow-helper.js', newServer);
|
||||
ns.scp('constants.js', newServer);
|
||||
let execExitCode = ns.exec('grow-helper.js', newServer, 10, 20);
|
||||
ns.tprint(`Exec 'grow-helper.js' exit code: ${execExitCode}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// let logFiles = ['hack-log.js', 'nuke-log.js'];
|
||||
|
||||
// for (let index = 0; index < logFiles.length; index++) {
|
||||
// const logFile = logFiles[index];
|
||||
// let portData = ns.readPort(index + 1);
|
||||
// if (portData != 'NULL PORT DATA') ns.write(logFile, portData, 'a');
|
||||
// }
|
||||
|
||||
await ns.sleep(1000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user