Remove bad scripts

This commit is contained in:
Isaac Shoebottom 2023-11-03 15:22:38 -03:00
parent 000e69a418
commit 374f14ea65
7 changed files with 0 additions and 160 deletions

View File

@ -1,13 +0,0 @@
/** @param {NS} ns */
export async function main(ns) {
let level = ns.getHackingLevel()
while (level < 999) {
let newLevel = ns.getHackingLevel()
if (newLevel !== level) {
ns.run("run.js")
}
level = newLevel
await ns.sleep(10 * 1000) // 10 seconds
}
}

View File

@ -1,4 +0,0 @@
/** @param {NS} ns */
export async function main(ns) {
ns.run("recursive-run.js", 1, "home", "hack-args.js")
}

View File

@ -1,15 +0,0 @@
/** @param {NS} ns */
export async function main(ns) {
let hostname = ns.args[0]
let cost = ns.args[1]
let moneyThresh = ns.getServerMaxMoney(hostname) * 0.75;
let securityThresh = ns.getServerMinSecurityLevel(hostname) + 5;
let numThreads = ns.getServerMaxRam(hostname) / cost
numThreads = Math.floor(numThreads)
if (numThreads < 1 || numThreads == Infinity) {
numThreads = 1
}
ns.spawn("hack.js", numThreads, hostname, moneyThresh, securityThresh)
}

View File

@ -1,33 +0,0 @@
/** @param {NS} ns */
export async function main(ns) {
let parent
if (ns.args[0] == undefined) {
parent = "home"
} else {
parent = ns.args[0]
}
let files = [
"hack-args.js",
"hack.js",
"root.js",
"recursive-copy.js",
"recursive-kill.js",
"recursive-run.js"
]
let script = "recursive-copy.js"
let servers = ns.scan()
for (const server of servers) {
if (server == parent) {
continue
}
if (server == "home") {
continue
}
//ns.tprint("Copied to: :", server)
ns.scp(files, server, "home")
ns.exec(script, server, 1, ns.getHostname()) // script, dest, thread count, arg1
}
}

View File

@ -1,26 +0,0 @@
/** @param {NS} ns */
export async function main(ns) {
let parent
if (ns.args[0] == undefined) {
parent = "home"
} else {
parent = ns.args[0]
}
let script = "recursive-kill.js"
let servers = ns.scan()
for (const server of servers) {
if (server == parent) {
continue
}
if (!ns.hasRootAccess(server)) {
ns.exec("root.js", ns.getHostname(), 1, server)
}
//ns.tprint("Killed all scripts on: ", server)
ns.killall(server, true)
ns.exec(script, server, 1, ns.getHostname())
}
}

View File

@ -1,30 +0,0 @@
/** @param {NS} ns */
export async function main(ns) {
let parent = ns.args[0]
let script = ns.args[1]
let selfScript = "recursive-run.js"
let servers = ns.scan()
//ns.tprint("INFO Scan of ", ns.getHostname(), ": ", servers)
for (const server of servers) {
if (server === parent) {
continue;
}
ns.exec(selfScript, server, 1, ns.getHostname(), script)
await ns.sleep(50)
let procs = ns.ps(server)
if (procs.length > 0) {
//ns.tprint("INFO Ram in use on ", server, ": ", ns.getServerUsedRam(server))
let ram = ns.getServerMaxRam(server) - ns.getServerUsedRam(server)
//ns.tprint("INFO Available ram on ", server, ": ", ram)
//ns.tprint("INFO Filename of running script: ", procs[0].filename)
}
if (ns.getServerRequiredHackingLevel(server) < ns.getHackingLevel()) {
// after thread args, first arg is the server it us running on, and then the cost of the hack script
ns.tprint("RUN Started hacking server: ", server)
ns.exec(script, server, 1, server, ns.getScriptRam("hack.js", server))
}
}
}

View File

@ -1,39 +0,0 @@
/** @param {NS} ns */
export async function main(ns) {
ns.run("recursive-kill.js")
await ns.sleep(1000)
ns.run("recursive-copy.js")
await ns.sleep(1000)
//home is first arg for root, hack-args is the script to run
ns.run("recursive-run.js", 1, "root-server", "hack-args.js")
//problem is that the scanning takes place on the same sever instead of the server that is the parent
//need last child of each node to spawn the process on parent, as spawning on on children always needs extra ram
//
//root scans nodes, saves to list
//the last execution of the exec on the last child passes in a flag to spawn on parent
//wait for the parent to finish using sleep (maybe find better way to syncronize)
//start hack-args function on parent
//
//each child becomes the "root" and repeats
// SCRATCH ALLAT
// its pretty much unsolveable, either way you go up or down the node tree, you end up with the problem
// not knowing if a server will have enough ram to run the hack args script, because the end node
// becomes circular. the only way to solve the problem would be to be able to have enough ram to call
// spawn after the for loop after recursive-run is called for all children in the for loop.
// so for now just will have to run a manual command for each sever with less than 8gb of ram
// a more elegant but more set in stone solution might be to just collect every unique hostname
// (print to console, but don't include parent, and exclude duplicates)
// and then just run an exec on each one in a for loop
//hack to get n00dles working, since it has low ram
await ns.sleep(1000)
ns.exec("hack-args.js", "n00dles", 1, "n00dles", 2.20)
// start auto upgrade if not running
if (!ns.isRunning("auto-upgrade.js")) {
ns.run("auto-upgrade.js")
}
}