README.md: update. kill.js: fix argument parser. lshw.js: add `-p` option. increase information given. main.js: fix error message. set saner defaults. hacker.js: split some functions into "lib_time.js" and "lib_score.js". ram.js: fix.
[?]
Apr 28, 2020, 10:07 PM
2WOLGB42T4EO7ZKLA5KFUYWVPTR6I3ET3FPJT4BSJFL43RRFRUBACDependencies
- [2]
MKHG4OQBmake worker scripts and worker script executor time-aware. - [3]
BKG7YVUVmain.js, hacker.js, servers.js, ram.js: refactor. - [4]
SLSWBNYTadded ram utilisation logic to `ram.js` and `servers.js`. split and refactored redundant code into separate library files. - [5]
Y5OWMCQRall: remove unecessary uses of `exec`. refactor. main.js: add RAM reservation logic. lib_ram.js: renamed to lib_ram_server.js. README.js: update. - [6]
VMXI7PS4added action cap. improved scoring system. fixed parts of security and cash predictors. made lshw loopable. - [7]
AXGQ7FMLsplit and refactor hacking logic to "hacker.js" and argument parsing and script execution logic to "main.js". update "README.md". - [8]
4ACCU75Nimprove and refactor scheduling logic. - [9]
6MBUKAG6remove unneeded functions and comments. update readme. - [10]
7SRULDRFminor refactoring. - [11]
NQ22FUSWadd more options to `main.js`. update `README.md`. - [12]
HSNSECD5all: refactor. main.js: fix call to `void_kill_script_named_server_named`. - [13]
P6ZJC2SHhacker.js: normalise factors used in server scoring function. - [14]
3NFCZ6IPfixed the ram utilisation logic. added flags to `main.js` that can prevent the execution of helpers. - [15]
2BKHJI2Sinit - [16]
DJDWBCCQadd missing "nop.js". killall.js: rename to kill.js. add `--script` and `--server` options. - [17]
CJBGAILAadd optional `--target` parameter for `main.js`. update `README.md`. - [18]
RWMZ7DVLsplit and refactor various logics. update "README.md".
Change contents
- replacement in sbin/ram.js at line 7[4.5418]→[4.5418:5436](∅→∅),[4.5436]→[3.854:928](∅→∅),[3.928]→[4.5436:5515](∅→∅),[4.5436]→[4.5436:5515](∅→∅)
for (;ns.getServerMoneyAvailable("home") >= ns.getUpgradeHomeRamCost() &&float_get_network_ram_utilisation(ns) > float_ram_utilisation_threshold;try {for (;ns.getServerMoneyAvailable("home") >= ns.getUpgradeHomeRamCost() &&float_get_network_ram_utilisation(ns) > float_ram_utilisation_threshold; - replacement in sbin/ram.js at line 13[4.7946]→[3.929:937](∅→∅),[3.937]→[4.8087:8099](∅→∅),[4.5522]→[4.8087:8099](∅→∅),[4.8087]→[4.8087:8099](∅→∅)
) {try {) - replacement in sbin/ram.js at line 15[3.967]→[4.5703:5727](∅→∅),[4.5703]→[4.5703:5727](∅→∅),[4.5727]→[3.968:1009](∅→∅),[4.98]→[4.8287:8295](∅→∅),[3.1009]→[4.8287:8295](∅→∅),[4.5804]→[4.8287:8295](∅→∅),[4.8287]→[4.8287:8295](∅→∅),[4.8295]→[3.1010:1052](∅→∅)
} catch (error) {ns.print(JSON.stringify(error));}await ns.sleep(float_period_check);} catch (error) {ns.print(JSON.stringify(error)); - replacement in sbin/hacker.js at line 1
/* hacker.js - 8.25GB - TODO:/* hacker.js - 8.75GB - TODO: - edit in sbin/hacker.js at line 7
import { array_get_servers_rooted } from "lib_root.js"; - edit in sbin/hacker.js at line 11
import {float_get_time_hack,float_get_time_grow,float_get_time_weaken,} from "lib_time.js"; - edit in sbin/hacker.js at line 17
import {float_get_server_score,array_get_servers_hackable,} from "lib_score.js"; - edit in sbin/hacker.js at line 157
const object_get_stats = function(ns) {// try {// return ns.getStats();// }// catch (error) {// ns.tprint(JSON.stringify(error));// return {// hacking: ns.getHackingLevel(),// strength: 1,// defense: 1,// dexterity: 1,// agility: 1,// charisma: 1,// intelligence: 1// };// }return {hacking: ns.getHackingLevel(),strength: 1,defense: 1,dexterity: 1,agility: 1,charisma: 1,intelligence: 1};}; - edit in sbin/hacker.js at line 171
// player statsobject_stats: object_get_stats(ns), - replacement in bin/main.js at line 37
throw (ns.tprint(`ERROR: `), new Error(string_message_error));throw (ns.tprint(`ERROR: ${integer_threads_nop}`), new Error(string_message_error)); - replacement in bin/main.js at line 42
let integer_job_cap = 2000;let integer_job_cap = 1000; - replacement in bin/main.js at line 44
let float_padding_seconds = 0.5;let float_padding_seconds = 1; - replacement in bin/lshw.js at line 1
// lshw.js - 2.45GB - Display information about one or more servers.// lshw.js - 7.25GB - Display information about one or more servers. TODO:// * add flags that prevent certain information from being displayed.import { object_parse_arguments } from "lib_minimist.js";import {float_get_time_hack,float_get_time_grow,float_get_time_weaken,} from "lib_time.js";import { float_get_server_score } from "lib_score.js"; - replacement in bin/lshw.js at line 13
let array_arguments = ns.args,float_sleep_duration = 0;for (;;) {// variableslet float_sleep_duration = 0,integer_precision = 2,array_servers = [];// argument parsingconst object_arguments = object_parse_arguments(ns.args);for (const string_argument in object_arguments)if (object_arguments.hasOwnProperty(string_argument)) {const argument_value = object_arguments[string_argument];switch (string_argument) {case "d":// fall-throughcase "delay":float_sleep_duration = 1e3 * argument_value;break;case "p":// fall-throughcase "precision":integer_precision = argument_value;break;case "_":array_servers = argument_value;break;default:const string_message_error = `Unknown argument passed: "${string_argument}".`;throw (ns.tprint(`ERROR: ${string_message_error}`), new Error(string_message_error));}}// mainfor (0 === array_servers.length && array_servers.push(ns.getHostName()); ; ) { - replacement in bin/lshw.js at line 46
integer_indices_0 < array_arguments.length;integer_indices_0 < array_servers.length; - replacement in bin/lshw.js at line 49
const string_argument = array_arguments[integer_indices_0];("--delay" !== string_argument && "-d" !== string_argument) ||((float_sleep_duration = 1e3 * array_arguments[integer_indices_0 + 1]),array_arguments.splice(integer_indices_0, 2));const string_server = array_servers[integer_indices_0]; - replacement in bin/lshw.js at line 51
void_print_information(ns, string_argument);void_print_information(ns, string_server, integer_precision); - replacement in bin/lshw.js at line 62
const void_print_information = function (ns, string_server) {const void_print_information = function (ns, string_server, integer_precision) { - replacement in bin/lshw.js at line 79[4.12629]→[4.12629:12716](∅→∅),[4.12716]→[4.19187:19265](∅→∅),[4.19265]→[4.12792:12880](∅→∅),[4.12792]→[4.12792:12880](∅→∅)
Maximum cash ($): ${float_cash_max}Current cash ($): ${float_cash_current.toFixed(2)}Current cash (%): ${((float_cash_current * 100) / float_cash_max).toFixed(2)}Minimum security: ${float_security_minimum}Current security: ${float_security_current}Maximum cash ($): ${float_cash_max.toFixed(integer_precision)}Current cash ($): ${float_cash_current.toFixed(integer_precision)}Current cash (%): ${((float_cash_current * 100) / float_cash_max).toFixed(integer_precision)}Minimum security: ${float_security_minimum.toFixed(integer_precision)}Current security: ${float_security_current.toFixed(integer_precision)} - replacement in bin/lshw.js at line 86
).toFixed(2)}).toFixed(integer_precision)} - replacement in bin/lshw.js at line 88
Hacking level needed: ${ns.getServerRequiredHackingLevel(string_server)}hack() time (s): ${float_get_time_hack(ns, string_server, float_security_current).toFixed(integer_precision)}grow() time (s): ${float_get_time_grow(ns, string_server, float_security_current).toFixed(integer_precision)}weaken() time (s): ${float_get_time_weaken(ns, string_server, float_security_current).toFixed(integer_precision)}Hacking level needed: ${ns.getServerRequiredHackingLevel(string_server)}Score: ${float_get_server_score(ns, string_server).toFixed(integer_precision)} - replacement in bin/lshw.js at line 94[4.13161]→[4.13161:13242](∅→∅),[4.13242]→[4.19365:19437](∅→∅),[4.19437]→[4.13312:13357](∅→∅),[4.13312]→[4.13312:13357](∅→∅),[4.13357]→[4.19438:19510](∅→∅)
RAM total (GB): ${float_ram_total}RAM used (GB): ${float_ram_used.toFixed(2)}RAM used (%): ${((float_ram_used * 100) / float_ram_total).toFixed(2)}RAM free (GB): ${float_ram_free.toFixed(2)}RAM free (%): ${((float_ram_free * 100) / float_ram_total).toFixed(2)}RAM total (GB): ${float_ram_total.toFixed(integer_precision)}RAM used (GB): ${float_ram_used.toFixed(integer_precision)}RAM used (%): ${((float_ram_used * 100) / float_ram_total).toFixed(integer_precision)}RAM free (GB): ${float_ram_free.toFixed(integer_precision)}RAM free (%): ${((float_ram_free * 100) / float_ram_total).toFixed(integer_precision)} - replacement in bin/kill.js at line 4
import {array_get_servers}from "lib_servers.js";import { array_get_servers } from "lib_servers.js";import { void_kill_script_named_server_named } from "lib_kill.js";import { object_parse_arguments } from "lib_minimist.js"; - edit in bin/kill.js at line 8
import {void_kill_script_named_server_named}from "lib_kill.js";import {object_parse_arguments}from "lib_minimist.js"; - replacement in bin/kill.js at line 22
array_scripts = argument_value;array_scripts.push(argument_value); - replacement in bin/kill.js at line 27
array_servers = argument_value;array_servers.push(argument_value); - replacement in README.md at line 11
* Reserve at least enough RAM to be able to run "hacker.js" (8.25 GB).* Reserve at least enough RAM to be able to run "hacker.js" (8.75 GB). - replacement in README.md at line 35
* SECONDS = The duration of delay between each job, in seconds. Should be a floating-point number > 0. Defaults to 0.5.* SECONDS = The duration of delay between each job, in seconds. Should be a floating-point number > 0. Defaults to 1. - replacement in README.md at line 43
* CAP = The maximum amount of jobs to execute per schedule. Should be an integer > 0. Defaults to 2000.* CAP = The maximum amount of jobs to execute per schedule. Should be an integer > 0. Defaults to 1000. - replacement in README.md at line 130
### "lshw.js" (2.45 GB)### "lshw.js" (7.25 GB) - replacement in README.md at line 135
`run lshw.js [OPTIONS] <ARGUMENT [ARGUMENT ...]>``run lshw.js [OPTIONS ...] <ARGUMENT [ARGUMENT ...]>` - edit in README.md at line 144
`-p, --precision <INTEGER>`* INTEGER = The decimal places to display floating point values with. Should be an integer >= 0. Defaults to 2. - replacement in README.md at line 149
`run lshw.js -d 1 home foodnstuff``run lshw.js -d 1 --precision=4 home foodnstuff` - replacement in README.md at line 151
* Causes the terminal to output up-to-date information about the "home" and "foodnstuff" servers every second.* Causes the terminal to output up-to-date information about the "home" and "foodnstuff" servers every second, using 4 decimal places for the floating point values it displays.