executables: dynamically load help messages. lshw.js, main.js: add options to change score correction method and score factor multipliers. README.md: update.

[?]
May 13, 2020, 2:21 PM
FBAPT2WW2IUZTIHZP3BMVWKAIAGICTTH2QRPLDJXWNSYBW5AMO6AC

Dependencies

  • [2] ZVQK2652 executables: fix help message.
  • [3] ZNH2OJ3C hacker.js, main.js: added continuous scheduling mode. README.md: update. credits to Mei for helping me figure out how to time the continuous mode and to Kozd for making `sort_by` work with methods.
  • [4] 2WOLGB42 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.
  • [5] NQ22FUSW add more options to `main.js`. update `README.md`.
  • [6] SXEJJKPI executables: add `--help` flag. hacker.js: change scheduling logic. refactor. kill.js: allow handling more than one server or script at a time. cyclic_weaken.js: add. README.md: update.
  • [7] 3NFCZ6IP fixed the ram utilisation logic. added flags to `main.js` that can prevent the execution of helpers.
  • [8] HLC2L3NJ add "tor.js" and "programs.js". use `minimist` for "main.js" argument parsing.
  • [9] VMXI7PS4 added action cap. improved scoring system. fixed parts of security and cash predictors. made lshw loopable.
  • [10] IVSW4A6P lib_score.js: normalised scores against average instead of using arbitrary values.
  • [11] HSNSECD5 all: refactor. main.js: fix call to `void_kill_script_named_server_named`.
  • [12] 2BKHJI2S init
  • [13] Y5OWMCQR all: remove unecessary uses of `exec`. refactor. main.js: add RAM reservation logic. lib_ram.js: renamed to lib_ram_server.js. README.js: update.
  • [14] 6TF4T3E2 lshw.js: fix function call typo.
  • [15] G7YVCY6H lib_score.js: refactor. add two functions for score correction. remove unneeded arbitrary hard-coded multipliers.
  • [*] 6MBUKAG6 remove unneeded functions and comments. update readme.
  • [*] DJDWBCCQ add missing "nop.js". killall.js: rename to kill.js. add `--script` and `--server` options.

Change contents

  • replacement in lib/lib_score.js at line 100
    [4.3522][4.3718051:3718120](),[4.3718051][4.3718051:3718120]()
    export const float_get_server_score = function (ns, string_server) {
    [4.3522]
    [4.3718120]
    export const float_get_server_score = function (
    ns,
    string_server,
    string_method_score_correction,
    float_multiplier_factor_skill_argument,
    float_multiplier_factor_max_cash_argument,
    float_multiplier_factor_growth_argument
    ) {
    let
    float_method_score_correction = float_get_standard_score,
    float_multiplier_factor_skill = 1,
    float_multiplier_factor_max_cash = 1,
    float_multiplier_factor_growth = 1;
    switch (string_method_score_correction) {
    case "standard":
    float_method_score_correction = float_get_standard_score;
    break;
    case "normal":
    float_method_score_correction = float_get_mean_normalised_score;
    break;
    default:
    ns.tprint(`WARNING: "${string_method_score_correction}" is not a valid value for the \`string_method_score_correction\` variable. Defaulting to "standard" method.`);
    }
    null !== float_multiplier_factor_skill_argument &&
    (float_multiplier_factor_skill = float_multiplier_factor_skill_argument),
    null !== float_multiplier_factor_max_cash_argument &&
    (float_multiplier_factor_max_cash = float_multiplier_factor_max_cash_argument),
    null !== float_multiplier_factor_growth_argument &&
    (float_multiplier_factor_growth = float_multiplier_factor_growth_argument);
  • edit in lib/lib_score.js at line 130
    [4.3718128][4.3523:3645]()
    // can change this to try different correction methods
    float_method_score_correction = float_get_standard_score,
  • replacement in lib/lib_score.js at line 168
    [4.3718743][4.2403:2464](),[4.2464][4.3718815:3718843](),[4.3718815][4.3718815:3718843]()
    1 * float_factor_skill +
    1 * float_factor_max_cash +
    1 * float_factor_growth
    [4.3718743]
    [4.3718843]
    float_multiplier_factor_skill * float_factor_skill +
    float_multiplier_factor_max_cash * float_factor_max_cash +
    float_multiplier_factor_growth * float_factor_growth
  • replacement in lib/lib_no_ns.js at line 10
    [2.245][2.245:263]()
    "'": "&apos",
    [2.245]
    [2.263]
    "'": "&#039",
  • replacement in bin/lshw.js at line 1
    [4.3795203][4.2217:2362]()
    // lshw.js - 7.25GB - Display information about one or more servers. TODO:
    // * add flags that prevent certain information from being displayed.
    [4.3795203]
    [2.9789]
    /* lshw.js - 7.25GB - Display information about one or more servers. TODO:
    * prevent parser from altering default values displayed in help message.
    * add flags that prevent certain information from being displayed.
    */
  • edit in bin/lshw.js at line 17
    [4.2578]
    [4.18242]
    const object_get_constants = function () {
    return {
    // default values
    object_defaults: {
    // decimal places to use for displaying numerical information
    integer_precision: 2,
    // multiplier for skill factor used in server scoring system
    float_multiplier_factor_skill: 1,
    // multiplier for max cash factor used in server scoring system
    float_multiplier_factor_max_cash: 1,
    // multiplier for growth factor used in server scoring system
    float_multiplier_factor_growth: 1,
    // correction method for factors used in server scoring system. can be "standard" or "normal"
    string_method_score_correction: "standard",
    float_sleep_duration: 0,
    },
    object_argument_names: {
    delay: {
    short: "d",
    long: "delay",
    },
    help: {
    short: "h",
    long: "help",
    },
    multiplier_skill: {
    short: "k",
    long: "multiplier-skill",
    },
    multiplier_cash: {
    short: "l",
    long: "multiplier-cash",
    },
    multiplier_growth: {
    short: "m",
    long: "multiplier-growth",
    },
    precision: {
    short: "p",
    long: "precision",
    },
    score_correction: {
    short: "q",
    long: "score-correction",
    },
    }
    }
    };
  • edit in bin/lshw.js at line 69
    [4.2594]
    [4.9969]
    const
    // defaults
    object_defaults = object_get_constants().object_defaults,
    // argument names
    object_argument_names = object_get_constants().object_argument_names;
  • replacement in bin/lshw.js at line 75
    [4.9975][4.9975:10005](),[4.10005][4.2626:2653](),[4.2626][4.2626:2653]()
    float_sleep_duration = 0,
    integer_precision = 2,
    [4.9975]
    [4.10006]
    // multiplier for skill factor used in server scoring system
    float_multiplier_factor_skill = object_defaults.float_multiplier_factor_skill,
    // multiplier for max cash factor used in server scoring system
    float_multiplier_factor_max_cash = object_defaults.float_multiplier_factor_max_cash,
    // multiplier for growth factor used in server scoring system
    float_multiplier_factor_growth = object_defaults.float_multiplier_factor_growth,
    // correction method for factors used in server scoring system. can be "standard" or "normal"
    string_method_score_correction = object_defaults.string_method_score_correction,
    float_sleep_duration = object_defaults.float_sleep_duration,
    integer_precision = object_defaults.integer_precision,
  • replacement in bin/lshw.js at line 93
    [4.2966][4.2966:2984]()
    case "d":
    [4.2966]
    [4.2984]
    case object_argument_names.delay.short:
  • replacement in bin/lshw.js at line 95
    [4.3008][4.3008:3030]()
    case "delay":
    [4.3008]
    [4.3030]
    case object_argument_names.delay.long:
  • replacement in bin/lshw.js at line 98
    [4.3102][4.10060:10078]()
    case "h":
    [4.3102]
    [4.10078]
    case object_argument_names.help.short:
  • replacement in bin/lshw.js at line 100
    [4.10102][4.10102:10123]()
    case "help":
    [4.10102]
    [4.10123]
    case object_argument_names.help.long:
  • replacement in bin/lshw.js at line 103
    [4.10187][4.3102:3120](),[4.3102][4.3102:3120]()
    case "p":
    [4.10187]
    [4.3120]
    case object_argument_names.multiplier_skill.short:
    // fall-through
    case object_argument_names.multiplier_skill.long:
    float_multiplier_factor_skill = argument_value;
    break;
    case object_argument_names.multiplier_cash.short:
    // fall-through
    case object_argument_names.multiplier_cash.long:
    float_multiplier_factor_max_cash = argument_value;
    break;
    case object_argument_names.multiplier_growth.short:
    // fall-through
    case object_argument_names.multiplier_growth.long:
    float_multiplier_factor_growth = argument_value;
    break;
    case object_argument_names.precision.short:
  • replacement in bin/lshw.js at line 120
    [4.3144][4.3144:3170]()
    case "precision":
    [4.3144]
    [4.3170]
    case object_argument_names.precision.long:
  • edit in bin/lshw.js at line 123
    [4.3233]
    [4.3233]
    case object_argument_names.score_correction.short:
    // fall-through
    case object_argument_names.score_correction.long:
    string_method_score_correction = argument_value;
    break;
  • replacement in bin/lshw.js at line 139
    [4.10214][4.10214:10265]()
    return void_print_help(ns, integer_precision);
    [4.10214]
    [4.1578]
    return void_print_help(ns);
  • replacement in bin/lshw.js at line 148
    [4.18777][4.3731:3801]()
    void_print_information(ns, string_server, integer_precision);
    [4.18777]
    [4.18830]
    void_print_information(
    ns,
    string_server,
    integer_precision,
    string_method_score_correction,
    float_multiplier_factor_skill,
    float_multiplier_factor_max_cash,
    float_multiplier_factor_growth
    );
  • replacement in bin/lshw.js at line 167
    [4.19014][4.10449:10514]()
    const void_print_help = function (
    ns,
    integer_precision
    ) {
    [4.19014]
    [4.10514]
    const void_print_help = function (ns) {
    const object_argument_names = object_get_constants().object_argument_names;
    const object_defaults = object_get_constants().object_defaults;
  • replacement in bin/lshw.js at line 177
    [4.10657][4.10657:10711]()
    run lshw.js [OPTIONS ...] <ARGUMENT [ARGUMENT ...]>
    [4.10657]
    [4.10711]
    run ${ns.getScriptName()} [OPTIONS ...] <ARGUMENT [ARGUMENT ...]>
  • edit in bin/lshw.js at line 180
    [4.10766]
    [4.10766]
    FLAGS
    -${object_argument_names.help.short}, --${object_argument_names.help.long}
    Displays this message then exits.
  • replacement in bin/lshw.js at line 186
    [4.10775][4.10775:10799]()
    -d, --delay <SECONDS>
    [4.10775]
    [4.10799]
    -${object_argument_names.delay.short}, --${object_argument_names.delay.long} <SECONDS>
  • replacement in bin/lshw.js at line 189
    [4.11010][4.11010:11171]()
    -p, --precision <INTEGER>
    INTEGER = The decimal places to display floating point values with. Should be an integer >= 0. Defaults to ${integer_precision}.
    [4.11010]
    [4.11171]
    -${object_argument_names.multiplier_skill.short}, --${object_argument_names.multiplier_skill.long} <FLOAT>
    FLOAT = The multiplier used to change the weight of the factor representing your skill against the target server used in the server scoring system. Should a floating point number. 1 = factor has normal importance, > 1 = factor has more importance, < 1 = factor has less importance, 0 = factor is not used, < 0 = factor has negative effect. Defaults to ${object_defaults.float_multiplier_factor_skill}.
    -${object_argument_names.multiplier_cash.short}, --${object_argument_names.multiplier_cash.long} <FLOAT>
    FLOAT = The multiplier used to change the weight of the factor representing the target server's maximum cash used in the server scoring system. Should a floating point number. 1 = factor has normal importance, > 1 = factor has more importance, < 1 = factor has less importance, 0 = factor is not used, < 0 = factor has negative effect. Defaults to ${object_defaults.float_multiplier_factor_max_cash}.
    -${object_argument_names.multiplier_growth.short}, --${object_argument_names.multiplier_growth.long} <FLOAT>
    FLOAT = The multiplier used to change the weight of the factor representing the target server's growth used in the server scoring system. Should a floating point number. 1 = factor has normal importance, > 1 = factor has more importance, < 1 = factor has less importance, 0 = factor is not used, < 0 = factor has negative effect. Defaults to ${object_defaults.float_multiplier_factor_growth}.
  • replacement in bin/lshw.js at line 198
    [4.11172][4.11172:11230]()
    FLAGS
    -h, --help
    Displays this message then exits.`
    [4.11172]
    [2.9889]
    -${object_argument_names.precision.short}, --${object_argument_names.precision.long} <INTEGER>
    INTEGER = The decimal places to display floating point values with. Should be an integer >= 0. Defaults to ${object_defaults.integer_precision}.
    -${object_argument_names.score_correction.short}, --${object_argument_names.score_correction.long} <METHOD>
    METHOD = The method used to correct the factors used in the server scoring system. Can be "standard" (uses standard scoring) or "normal" (uses mean normalised scoring). Defaults to "${object_defaults.string_method_score_correction}".`
  • replacement in bin/lshw.js at line 210
    [4.11300][4.11300:11320]()
    integer_precision
    [4.11300]
    [4.11320]
    integer_precision,
    string_method_score_correction,
    float_multiplier_factor_skill,
    float_multiplier_factor_max_cash,
    float_multiplier_factor_growth
  • replacement in bin/lshw.js at line 244
    [4.4693][4.4693:4774]()
    Score: ${float_get_server_score(ns, string_server).toFixed(integer_precision)}
    [4.4693]
    [4.13091]
    Score: ${float_get_server_score(
    ns,
    string_server,
    string_method_score_correction,
    float_multiplier_factor_skill,
    float_multiplier_factor_max_cash,
    float_multiplier_factor_growth
    ).toFixed(integer_precision)}
  • edit in bin/kill.js at line 12
    [4.3798994]
    [4.11939]
    const object_get_constants = function () {
    return {
    object_argument_names: {
    script: {
    short: "c",
    long: "script",
    },
    server: {
    short: "e",
    long: "server",
    },
    help: {
    short: "h",
    long: "help",
    },
    }
    }
    };
  • replacement in bin/kill.js at line 39
    [4.3799258][4.3799258:3799318]()
    const object_arguments = object_parse_arguments(ns.args);
    [4.3799258]
    [4.3799318]
    const
    object_argument_names = object_get_constants().object_argument_names,
    object_arguments = object_parse_arguments(ns.args);
  • replacement in bin/kill.js at line 46
    [4.3799525][4.3799525:3799543]()
    case "c":
    [4.3799525]
    [4.3799543]
    case object_argument_names.script.short:
  • replacement in bin/kill.js at line 48
    [4.3799567][4.3799567:3799590]()
    case "script":
    [4.3799567]
    [4.12066]
    case object_argument_names.script.long:
  • replacement in bin/kill.js at line 53
    [4.3799649][4.3799649:3799667]()
    case "e":
    [4.3799649]
    [4.3799667]
    case object_argument_names.server.short:
  • replacement in bin/kill.js at line 55
    [4.3799691][4.3799691:3799714]()
    case "server":
    [4.3799691]
    [4.12213]
    case object_argument_names.server.long:
  • replacement in bin/kill.js at line 60
    [4.12376][4.12376:12394]()
    case "h":
    [4.12376]
    [4.12394]
    case object_argument_names.help.short:
  • replacement in bin/kill.js at line 62
    [4.12418][4.12418:12439]()
    case "help":
    [4.12418]
    [4.12439]
    case object_argument_names.help.long:
  • replacement in bin/kill.js at line 64
    [4.5409][4.3799756:3799773](),[4.12486][4.3799756:3799773](),[4.3799756][4.3799756:3799773]()
    break;
    [4.12486]
    [4.3799773]
    break;;
  • edit in bin/kill.js at line 89
    [4.12587]
    [4.12587]
    const object_argument_names = object_get_constants().object_argument_names;
  • replacement in bin/kill.js at line 99
    [4.12818][4.12818:12858]()
    run kill.js [FLAGS ...] [OPTIONS ...]
    [4.12818]
    [4.12858]
    run ${ns.getScriptName()} [FLAGS ...] [OPTIONS ...]
    FLAGS
    -${object_argument_names.help.short}, --${object_argument_names.help.long}
    Displays this message then exits.
  • replacement in bin/kill.js at line 106
    [4.12867][4.12867:12891]()
    -c, --script <SCRIPT>
    [4.12867]
    [4.12891]
    -${object_argument_names.script.short}, --${object_argument_names.script.long} <SCRIPT>
  • replacement in bin/kill.js at line 109
    [4.12935][4.12935:13085]()
    -e, --server <SERVER>
    SERVER = The name of a server on which scripts will be killed.
    FLAGS
    -h, --help
    Displays this message then exits.`
    [4.12935]
    [2.9997]
    -${object_argument_names.server.short}, --${object_argument_names.server.long} <SERVER>
    SERVER = The name of a server on which scripts will be killed.`
  • edit in bin/cp.js at line 8
    [4.19621]
    [4.3803100]
    const object_get_constants = function () {
    return {
    object_argument_names: {
    help: {
    short: "h",
    long: "help",
    },
    }
    }
    };
  • replacement in bin/cp.js at line 23
    [4.13893][4.13893:13953]()
    const object_arguments = object_parse_arguments(ns.args);
    [4.13893]
    [4.13953]
    const
    object_argument_names = object_get_constants().object_argument_names,
    object_arguments = object_parse_arguments(ns.args);
  • replacement in bin/cp.js at line 31
    [4.14189][4.14189:14207]()
    case "h":
    [4.14189]
    [4.14207]
    case object_argument_names.help.short:
  • replacement in bin/cp.js at line 33
    [4.14231][4.14231:14252]()
    case "help":
    [4.14231]
    [4.14252]
    case object_argument_names.help.long:
  • edit in bin/cp.js at line 62
    [4.15027]
    [4.15027]
    const object_argument_names = object_get_constants().object_argument_names;
  • replacement in bin/cp.js at line 69
    [4.15174][4.15174:15224]()
    run cp.js [FLAGS ...] <ARGUMENT [ARGUMENT ...]>
    [4.15174]
    [4.15224]
    run ${ns.getScriptName()} [FLAGS ...] <ARGUMENT [ARGUMENT ...]>
  • replacement in bin/cp.js at line 74
    [4.15323][4.15323:15336]()
    -h, --help
    [4.15323]
    [4.15336]
    -${object_argument_names.help.short}, --${object_argument_names.help.long}
  • edit in README.md at line 44
    [3.1823]
    [4.7684]
    `-g, --no-programs`
  • edit in README.md at line 47
    [4.7685]
    [4.15806]
    * Prevents the "programs.js" script from being started which is responsible for buying programs from the "darkweb" server.
  • edit in README.md at line 53
    [4.15863][4.6072:6221](),[4.7685][4.6072:6221]()
    `-g, --no-programs`
    * Prevents the "programs.js" script from being started which is responsible for buying programs from the "darkweb" server.
  • edit in README.md at line 56
    [4.4604]
    [17.3558]
    `-u, --no-cyclic-weaken`
  • edit in README.md at line 59
    [17.3559]
    [18.9897]
    * Prevents the "cyclic_weaken.js" script from being started which is responsible for running `weaken` continuously to gain hacking experience.
  • edit in README.md at line 93
    [4.17731]
    `-k, --multiplier-skill <FLOAT>`
    FLOAT = The multiplier used to change the weight of the factor representing your skill against the target server used in the server scoring system. Should a floating point number. 1 = factor has normal importance, > 1 = factor has more importance, < 1 = factor has less importance, 0 = factor is not used, < 0 = factor has negative effect. Defaults to 1.
    `-l, --multiplier-cash <FLOAT>`
    FLOAT = The multiplier used to change the weight of the factor representing the target server's maximum cash used in the server scoring system. Should a floating point number. 1 = factor has normal importance, > 1 = factor has more importance, < 1 = factor has less importance, 0 = factor is not used, < 0 = factor has negative effect. Defaults to 1.
    `-m, --multiplier-growth <FLOAT>`
    FLOAT = The multiplier used to change the weight of the factor representing the target server's growth used in the server scoring system. Should a floating point number. 1 = factor has normal importance, > 1 = factor has more importance, < 1 = factor has less importance, 0 = factor is not used, < 0 = factor has negative effect. Defaults to 1.
    `-q, --score-correction <METHOD>`
    METHOD = The method used to correct the factors used in the server scoring system. Can be "standard" (uses standard scoring) or "normal" (uses mean normalised scoring). Defaults to "standard".
    `-v, --ram-cyclic-weaken <FLOAT>`
    FLOAT = The fraction of the botnet's available RAM to be used to run cyclic_weaken.js. Should be a floating point number > 0. Defaults to 0.5.
    #### EXAMPLES
    `run main.js`
    * Runs the script using default values.
    `run main.js -ao --no-botnet --job-cap 4000 -i "harakiri-sushi" -r 0.7 --steal-cap=0.5 -q normal`
    * Runs the script with up to 4000 jobs, targetting "harakiri-sushi", only upgrading/replacing servers when at least 0.7 of your network's total RAM is being used, stealing only up to 50% of harakiri-sushi's cash per "hack.js" job that finishes executing, and using the "mean normalised" score correction method, whilst the remaining variables are set to defaults. The "ram.js", "tor.js" and "botnet.js" helper scripts are also prevented from starting.
    ---
    ### "kill.js" (2.55 GB)
    * Kill all running scripts.
    * Optionally, kill only named scripts instead.
    * Optionally, kill only scripts on named servers instead.
    * Optionally, kill only named scripts on named servers instead.
    #### USAGE
    `run kill.js [FLAGS ...] [OPTIONS ...]`
    #### FLAGS
    `-h, --help`
    * Displays a help message then exits.
    #### OPTIONS
    `-c, --script <SCRIPT>`
    * SCRIPT = The name of a script to kill.
    `-e, --server <SERVER>`
    * SERVER = The name of a server on which scripts will be killed.
    #### EXAMPLES
    `run kill.js`
    * Kills all running scripts.
    `run kill.js -c grow.js --script hack.js`
    * Kills all scripts named "grow.js" and "hack.js" on any servers that they are currently running on.
    `run kill.js -e home --server harakiri-sushi`
    * Kills all scripts currently running on the "home" and "harakiri-sushi" servers.
    `run kill.js -c grow.js --script hack.js -e home --server harakiri-sushi`
    * Kills all scripts named "grow.js" and "hack.js" currently running on the "home" and "harakiri-sushi" servers.
    ---
    ### "lshw.js" (7.25 GB)
    * Display information about one or more servers.
    * Optionally, display the information at regular intervals.
    #### USAGE
    `run lshw.js [FLAGS ...] [OPTIONS ...] <ARGUMENT [ARGUMENT ...]>`
    * ARGUMENT = Server to display the information about.
    #### FLAGS
    `-h, --help`
    * Displays a help message then exits.
    #### OPTIONS
    `-d, --delay <SECONDS>`
    * SECONDS = The duration of delay between update, in seconds. Should be a floating-point number >= 0.001. By default, the script will only display server information once, unless this option is manually set.
    `-p, --precision <INTEGER>`
    * INTEGER = The decimal places to display floating point values with. Should be an integer >= 0. Defaults to 2.
    #### EXAMPLES
    `run lshw.js -d 1 --precision=4 home foodnstuff`
    * 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.
    ---
    ### "cp.js" (2.65 GB)
    * Copy all files that contain particular substring(s) in their filenames from all servers to the current server.
    #### USAGE
    `run cp.js [FLAGS ...] <ARGUMENT [ARGUMENT ...]>`
    * ARGUMENT = Substring contained in the names of files to be copied to the current server.
    #### FLAGS
    `-h, --help`
    * Displays a help message then exits.
    #### EXAMPLES
    `run cp.js .lit .script .txt`
    * Copies all files that contain the strings ".lit", ".script" or ".txt" in their filename from all servers to the current server.
    ---
    ## Installation
    Save all the `.js` files in this repository to the root directory of the "home" server using the same filenames that they currently have in this repository.
    ---
    ## License
    This Work is distributed and dual-licensed under the terms of both the [MIT License](https://nest.pijul.com/nicoty/bitburner_scripts:master/4bb17ded7a86f7decd) and the [Apache License 2.0](https://nest.pijul.com/nicoty/bitburner_scripts:master/4bb17ded7a86f7de02).
    ### Contribution
    Unless You explicitly state otherwise, any Contribution submitted for inclusion in the Work by You, as defined in the Apache License 2.0, shall be dual-licensed as above, without any additional terms or conditions.