add more options to `main.js`. update `README.md`.

[?]
Apr 19, 2020, 2:29 PM
NQ22FUSWN6CBJKJ5H7UV5N2KEXBIXVNQDNL2EK6UJ3E7RFLWNVDQC

Dependencies

  • [2] 2LU5Y77O fixed optimum percentage to steal calculator.
  • [3] HHZNTFCT remove `-t` flag for `main.js` which conflicted with the same flag for the `run` command.
  • [4] 2BKHJI2S init
  • [5] 6MBUKAG6 remove unneeded functions and comments. update readme.
  • [6] CJBGAILA add optional `--target` parameter for `main.js`. update `README.md`.
  • [7] VMXI7PS4 added action cap. improved scoring system. fixed parts of security and cash predictors. made lshw loopable.
  • [8] FA3U4WUJ more `README.md` changes.
  • [9] BZ6FC2BT add `cp.js`.
  • [10] YANDOFZ4 added readme and licenses
  • [11] VHWFHMNW 2nd attempt to fix percentage to steal
  • [12] 3TYF4BJS target only hackable servers. replace servers continually.
  • [13] BCM3TZOS added `killall.js` option to kill only named scripts. fixed `void_server_buy_or_upgrade` regression that prevented it from working when you don't have servers.
  • [14] EYKBOK3O optimised the scheduling logic by ensuring that cycles start and finish at minimum security of target.

Change contents

  • edit in lib/lib.js at line 1
    [3.3736162][3.3736162:3736612](),[3.3736612][3.1576:1671](),[3.1671][3.3736717:3736738](),[3.3736717][3.3736717:3736738](),[3.3736921][3.3736921:3737105](),[3.3737105][3.1576:1709](),[3.1709][3.3737105:3737127](),[3.3737105][3.3737105:3737127]()
    // outputs function names and arguments passed to them.
    const void_debug = function() {
    const boolean_on = false;
    const array_arguments = Array.from(arguments);
    if (boolean_on) {
    const ns = array_arguments[1][0];
    for (let integer_indices_0 = 0; integer_indices_0 < array_arguments[1].length; ++integer_indices_0) {
    const string_argument_type = typeof(array_arguments[1][integer_indices_0]);
    if (integer_indices_0 === 0) {
    ns.tprint(`${new Date().toISOString()}: ${array_arguments[integer_indices_0].name}(`);
    }
    else {
    if (integer_indices_0 === array_arguments[1].length - 1) {
    ns.tprint(`${string_argument_type}: ${JSON.stringify(array_arguments[1][integer_indices_0])})`);
    }
    else {
    ns.tprint(`${string_argument_type}: ${JSON.stringify(array_arguments[1][integer_indices_0])}, `);
    }
    }
    }
    }
    };
  • replacement in lib/lib.js at line 2
    [3.3737171][3.3737171:3737230]()
    void_debug(object_get_constants, Array.from(arguments));
    [3.3737171]
    [3.3737230]
    // from BitNode/BitNodeMultipliers
  • edit in lib/lib.js at line 215
    [3.1731][3.1731:1790]()
    // void_debug(array_get_servers, Array.from(arguments));
  • edit in lib/lib.js at line 229
    [3.3743555][3.3743555:3743611]()
    void_debug(array_get_servers, Array.from(arguments));
  • edit in lib/lib.js at line 244
    [3.3744287][3.3744287:3744354]()
    void_debug(integer_get_server_ram_total, Array.from(arguments));
  • edit in lib/lib.js at line 249
    [3.3744504][3.3744504:3744568]()
    void_debug(float_get_server_ram_used, Array.from(arguments));
  • edit in lib/lib.js at line 254
    [3.3744728][3.3744728:3744792]()
    void_debug(float_get_server_ram_free, Array.from(arguments));
  • edit in lib/lib.js at line 261
    [3.3745043][3.3745043:3745112]()
    void_debug(boolean_servers_bought_all_max, Array.from(arguments));
  • edit in lib/lib.js at line 275
    [3.3745672][3.3745672:3745744]()
    void_debug(string_get_server_bought_smallest, Array.from(arguments));
  • edit in lib/lib.js at line 292
    [3.3746523][3.3746523:3746594]()
    void_debug(string_get_server_bought_biggest, Array.from(arguments));
  • edit in lib/lib.js at line 309
    [3.3747404][3.3747404:3747482]()
    void_debug(integer_get_server_ram_biggest_afforded, Array.from(arguments));
  • edit in lib/lib.js at line 319
    [3.3748188][3.3748188:3748253](),[3.3749734][3.3749734:3749735]()
    void_debug(void_server_buy_or_upgrade, Array.from(arguments));
  • edit in lib/lib.js at line 407
    [3.3751802][3.3751802:3751867]()
    void_debug(array_get_servers_unrooted, Array.from(arguments));
  • edit in lib/lib.js at line 419
    [3.3752891][3.3752891:3752949]()
    void_debug(void_open_ports_try, Array.from(arguments));
  • edit in lib/lib.js at line 432
    [3.3754888][3.3754888:3754951]()
    void_debug(void_open_ports_nuke_try, Array.from(arguments));
  • edit in lib/lib.js at line 449
    [3.3755494][3.3755494:3755556]()
    void_debug(void_sort_by_server_ram, Array.from(arguments));
  • edit in lib/lib.js at line 454
    [3.1644][3.1644:1705]()
    void_debug(float_get_server_score, Array.from(arguments));
  • edit in lib/lib.js at line 460
    [3.3756389][3.3756389:3756454]()
    void_debug(void_sort_by_server_scores, Array.from(arguments));
  • edit in lib/lib.js at line 468
    [3.3756730][3.3756730:3756793]()
    void_debug(array_get_servers_rooted, Array.from(arguments));
  • edit in lib/lib.js at line 480
    [3.3758373][3.3758373:3758441]()
    void_debug(integer_get_corrected_threads, Array.from(arguments));
  • edit in lib/lib.js at line 492
    [3.3758885][3.3758885:3758963]()
    void_debug(integer_get_threads_required_for_weaken, Array.from(arguments));
  • edit in lib/lib.js at line 498
    [3.1708][3.1708:1803]()
    void_debug(integer_get_threads_required_for_weaken_minimum_security, Array.from(arguments));
  • edit in lib/lib.js at line 503
    [3.3759961][3.3759961:3760026]()
    void_debug(integer_get_threads_weaken, Array.from(arguments));
  • edit in lib/lib.js at line 510
    [3.2181][3.2181:2259]()
    void_debug(float_get_security_decrease_from_weaken, Array.from(arguments));
  • edit in lib/lib.js at line 517
    [3.3760912][3.3760912:3760982]()
    void_debug(integer_get_threads_for_growth, Array.from(arguments));
  • edit in lib/lib.js at line 532
    [3.3761835][3.3761835:3761905]()
    void_debug(integer_get_threads_for_growth, Array.from(arguments));
  • edit in lib/lib.js at line 547
    [3.2491][3.2491:2580]()
    void_debug(integer_get_threads_required_for_grow_maximum_cash, Array.from(arguments));
  • edit in lib/lib.js at line 552
    [3.3763420][3.3763420:3763483]()
    void_debug(integer_get_threads_grow, Array.from(arguments));
  • edit in lib/lib.js at line 559
    [3.3615][3.3615:3691]()
    void_debug(float_get_security_increase_from_grow, Array.from(arguments));
  • edit in lib/lib.js at line 566
    [3.3764376][3.3764376:3764467]()
    void_debug(float_get_percentage_of_cash_from_available_per_hack, Array.from(arguments));
  • edit in lib/lib.js at line 580
    [3.2901][3.2901:2987]()
    void_debug(integer_get_threads_required_to_hack_percentage, Array.from(arguments));
  • edit in lib/lib.js at line 585
    [3.3765944][3.3765944:3766007]()
    void_debug(integer_get_threads_hack, Array.from(arguments));
  • edit in lib/lib.js at line 592
    [3.4573][3.4573:4650]()
    void_debug(float_get_security_increase_from_hack, Array.from(arguments));
  • edit in lib/lib.js at line 605
    [3.3766810][3.3766810:3766915]()
    void_debug(integer_get_threads_required_for_cash_grow_after_percentage_stolen, Array.from(arguments));
  • edit in lib/lib.js at line 610
    [2.1776][2.1776:1858]()
    void_debug(boolean_is_ram_enough_after_hack_percentage, Array.from(arguments));
  • edit in lib/lib.js at line 636
    [3.1659][3.1659:1740]()
    void_debug(integer_get_cycles_for_bisection_precision, Array.from(arguments));
  • edit in lib/lib.js at line 641
    [3.6202][3.3768770:3768838](),[3.7006][3.3768770:3768838](),[3.3768770][3.3768770:3768838]()
    void_debug(float_get_percentage_to_steal, Array.from(arguments));
  • edit in lib/lib.js at line 668
    [3.3769854][3.3769854:3769933]()
    void_debug(void_copy_files_to_string_servers_rooted, Array.from(arguments));
  • edit in lib/lib.js at line 680
    [3.3770508][3.3770508:3770585]()
    void_debug(array_get_servers_rooted_sorted_by_ram, Array.from(arguments));
  • edit in lib/lib.js at line 686
    [3.3770796][3.3770796:3770875]()
    void_debug(array_get_servers_rooted_sorted_by_score, Array.from(arguments));
  • edit in lib/lib.js at line 692
    [3.6049][3.2601:2692]()
    void_debug(string_get_server_rooted_hackable_with_score_biggest, Array.from(arguments));
  • edit in lib/lib.js at line 703
    [3.1829][3.1829:1885]()
    void_debug(string_job_decide, Array.from(arguments));
  • edit in lib/lib.js at line 717
    [2.2797][2.2797:2873]()
    void_debug(boolean_can_server_run_script_threads, Array.from(arguments));
  • edit in lib/lib.js at line 727
    [3.7420][3.3772706:3772764](),[3.3772706][3.3772706:3772764]()
    void_debug(float_get_time_hack, Array.from(arguments));
  • edit in lib/lib.js at line 748
    [3.7629][3.3773733:3773791](),[3.3773733][3.3773733:3773791]()
    void_debug(float_get_time_grow, Array.from(arguments));
  • edit in lib/lib.js at line 755
    [3.7835][3.3774227:3774287](),[3.3774227][3.3774227:3774287]()
    void_debug(float_get_time_weaken, Array.from(arguments));
  • edit in lib/lib.js at line 762
    [3.1787][3.1787:1853]()
    void_debug(array_make_schedule_weaken, Array.from(arguments));
  • edit in lib/lib.js at line 833
    [3.1727][3.3774575:3774634](),[3.2034][3.3774575:3774634](),[3.2787][3.3774575:3774634](),[3.8066][3.3774575:3774634](),[3.3774575][3.3774575:3774634]()
    void_debug(array_make_schedule, Array.from(arguments));
  • edit in lib/lib.js at line 1010
    [3.3784537][3.3784537:3784599]()
    void_debug(void_exec_script_weaken, Array.from(arguments));
  • edit in lib/lib.js at line 1015
    [3.3784916][3.3784916:3784976]()
    void_debug(void_exec_script_grow, Array.from(arguments));
  • edit in lib/lib.js at line 1020
    [3.3785291][3.3785291:3785351]()
    void_debug(void_exec_script_hack, Array.from(arguments));
  • edit in lib/lib.js at line 1026
    [3.2110][3.3785729:3785788](),[3.3474][3.3785729:3785788](),[3.11151][3.3785729:3785788](),[3.3785729][3.3785729:3785788]()
    void_debug(void_schedule_runner, Array.from(arguments));
  • replacement in bin/main.js at line 12
    [3.11329][3.1579:1626](),[3.3793864][3.1579:1626]()
    const string_servers_bought_name = "server";
    [3.11329]
    [3.3780]
    let string_servers_bought_name = "server";
  • replacement in bin/main.js at line 14
    [3.3870][3.2483:2516]()
    const integer_job_cap = 4000;
    [3.3870]
    [3.3903]
    let integer_job_cap = 2000;
  • replacement in bin/main.js at line 16
    [3.3934][2.4767:4804]()
    const float_padding_seconds = 0.4;
    [3.3934]
    [3.11493]
    let float_padding_seconds = 0.4;
  • replacement in bin/main.js at line 18
    [3.11546][2.4805:4838]()
    const float_precision = 0.001;
    [3.11546]
    [3.11547]
    let float_precision = 0.001;
  • replacement in bin/main.js at line 20
    [3.11619][2.4839:4871]()
    const float_steal_cap = 0.96;
    [3.11619]
    [3.11651]
    let float_steal_cap = 0.96;
  • replacement in bin/main.js at line 22
    [3.11706][3.3794209:3794250](),[3.3794209][3.3794209:3794250]()
    const float_period_check_seconds = 10;
    [3.11706]
    [3.2312]
    let float_period_check_seconds = 10;
  • edit in bin/main.js at line 29
    [3.2547]
    [3.2547]
    if (
    (string_argument === "--server-name") ||
    (string_argument === "-n")
    ) {
    string_servers_bought_name = array_arguments[integer_indices_0 + 1];
    }
  • replacement in bin/main.js at line 36
    [3.2556][3.3972:4011]()
    (string_argument === "--target")
    [3.2556]
    [3.2631]
    (string_argument === "--job-cap") ||
    (string_argument === "-j")
    ) {
    integer_job_cap = array_arguments[integer_indices_0 + 1];
    }
    if (
    (string_argument === "--job-delay") ||
    (string_argument === "-d")
    ) {
    float_padding_seconds = array_arguments[integer_indices_0 + 1];
    }
    if (
    (string_argument === "--precision") ||
    (string_argument === "-p")
    ) {
    float_precision = array_arguments[integer_indices_0 + 1];
    }
    if (
    (string_argument === "--steal-cap") ||
    (string_argument === "-s")
    ) {
    float_steal_cap = array_arguments[integer_indices_0 + 1];
    }
    if (
    (string_argument === "--check-delay") ||
    (string_argument === "-c")
    ) {
    float_period_check_seconds = array_arguments[integer_indices_0 + 1];
    }
    if (
    (string_argument === "--target") ||
    (string_argument === "-i")
  • replacement in bin/lshw.js at line 41
    [3.13737][3.13737:13815]()
    (string_argument === "--sleep") ||
    (string_argument === "-s")
    [3.13737]
    [3.13815]
    (string_argument === "--delay") ||
    (string_argument === "-d")
  • edit in README.md at line 2
    [3.7087][3.7087:7102](),[3.2863][3.2863:3091]()
    ## Description
    Scripts for the game [Bitburner](https://github.com/danielyxie/bitburner). Here's an overview of what the executable scripts (located in the `bin` directory) are supposed to do, the RAM they require and any arguments they take:
  • replacement in README.md at line 3
    [3.3873314][3.4219:4262]()
    ### `main.js [--target SERVER]` (15.70 GB)
    [3.3873314]
    [3.3118]
    Scripts for the game [Bitburner](https://github.com/danielyxie/bitburner).
    ---
    ## Overview
    Here's an overview of what the executable scripts (located in the `bin` directory of this repository) are supposed to do, as well as usage information and examples for each one:
    ### `main.js` (15.70 GB)
  • replacement in README.md at line 17
    [3.3499][3.2967:3043]()
    * Optionally, target the a named server instead of picking one by itself.
    [3.3499]
    [3.3499]
    #### USAGE
    `run main.js [OPTIONS]`
    #### OPTIONS
    `-c, --check-delay <SECONDS>`
    * SECONDS = The duration of delay between each checking done for the completion of the main cycle, in seconds. Should be a floating-point number > 0. Defaults to 10.
    `-d, --job-delay <SECONDS>`
    * SECONDS = The duration of delay between each job, in seconds. Should be a floating-point number > 0. Defaults to 0.4.
    `-i, --target <SERVER>`
    * SERVER = The server that should be targetted by the `weaken`, `grow` and `hack` functions. Should be a string. Defaults to choosing an optimal target using a scroing system based on the server's maximum cash, growth, required hacking level, and the player's current hacking level.
    `-j, --job-cap <CAP>`
  • replacement in README.md at line 36
    [3.3500][3.3044:3095]()
    ### `killall.js [SCRIPT1 [SCRIPT2 ...]]` (3.05 GB)
    [3.3500]
    [3.3528]
    * CAP = The maximum amount of jobs to start per cycle. Should be an integer > 0. Defaults to 2000.
    `-n, --server-name <NAME>`
    * NAME = The name to be used for purchased servers. Should be a string. Defaults to "server".
    `-p, --precision <PRECISION>`
    * PRECISION = A value used in determining how many cycles of bisection the binary search algorithm used for the percentage to steal calculator should use. Should be a floating point number > 0 <= 1. Values closer to 0 will result in greater precision in the calculation, but potentially longer run-times and compared to values closer to 1. Defaults to 0.001.
    `-s, --steal-cap <CAP>`
    * CAP = The maximum amount fraction of cash to steal from the target server per `hack` job. Should be an integer >= 0 <=1. Defaults to 0.96.
    #### EXAMPLES
    `run main.js`
    * Runs the script using default values.
    `run main.js --job-cap 4000 -i "harakiri-sushi" -s 0.5`
    * Runs the script with up to 4000 jobs, targetting "harakiri-sushi" and stealing up to 50% of it's cash per `hack` job, whilst the remaining variables are set to defaults.
    ---
    ### `killall.js` (3.05 GB)
  • replacement in README.md at line 65
    [3.3559][3.3161:3223]()
    ### `lshw.js [-s INTERVAL] <SERVER1 [SERVER2 ...]>` (2.45 GB)
    [3.3559]
    [3.3600]
    #### USAGE
    `run killall.js [ARGUMENT ...]`
    * ARGUMENT = Name of the script to kill. To kill more than one named script, pass them all as arguments to the command, each separated by a space.
    #### EXAMPLES
    `run killall.js grow.js hack.js`
    * Kills all scripts named `grow.js` and `hack.js` on any servers that they are currently running on.
    ---
    ### `lshw.js` (2.45 GB)
  • replacement in README.md at line 79
    [3.3651][3.14285:14408]()
    * Optionally, display the information at regular intervals. The INTERVAL parameter accepts a value >= 1 in milliseconds.
    [3.3651]
    [3.3873389]
    * Optionally, display the information at regular intervals.
    #### USAGE
    `run lshw.js [OPTIONS] <ARGUMENT [ARGUMENT ...]>`
    * ARGUMENT = Server to display the information about.
    #### OPTIONS
    `-d, --delay <MILLISECONDS>`
    * MILLISECONDS = The duration of delay between update, in milliseconds. Should be a floating-point number >= 1. By default, the script will only display server information once, unless this option is manually set.
    #### EXAMPLES
    `run lshw.js -s 1000 home foodnstuff`
    * Causes the terminal to output up-to-date information about the "home" and "foodnstuff" servers every second.
    ---
  • replacement in README.md at line 98
    [3.3873390][3.2952:3004]()
    ### `cp.js <SUBSTRING1 [SUBSTRING2 ...]>` (2.65 GB)
    [3.3873390]
    [3.3004]
    ### `cp.js` (2.65 GB)
  • replacement in README.md at line 101
    [3.3669][3.3120:3136](),[3.3136][3.3669:3760](),[3.3669][3.3669:3760]()
    ## Installation
    Save all the `.js` files in this repository to the "home" server using the same filenames.
    [3.3669]
    [3.3760]
    #### USAGE
    `run cp.js <ARGUMENT [ARGUMENT ...]>`
  • replacement in README.md at line 104
    [3.3761][3.3761:3770](),[3.1691][3.1691:1756]()
    ## Usage
    Here are some usage examples and the effects that should follow:
    [3.3761]
    [3.3770]
    * ARGUMENT = Substring contained in the names of files to be copied to the current server.
  • replacement in README.md at line 106
    [3.14448][3.3771:3791](),[3.3771][3.3771:3791](),[3.3791][3.1757:1788]()
    ```
    run main.js
    ```
    Starts the main daemon script.
    [3.3771]
    [3.14449]
    #### EXAMPLES
    `run cp.js .lit .script .txt`
  • replacement in README.md at line 109
    [3.14483][3.3794:3798](),[3.3794][3.3794:3798](),[3.3798][3.14484:14520](),[3.14520][3.3830:3834](),[3.3830][3.3830:3834](),[3.3834][3.1789:1898]()
    ```
    run lshw.js -s 1000 home foodnstuff
    ```
    Causes the terminal to output up-to-date information about the "home" and "foodnstuff" servers every second.
    [3.14450]
    [3.3393]
    * Copies all files that contain the strings ".lit", ".script" or ".txt" in their filename from all servers to the current server.
  • replacement in README.md at line 111
    [3.3394][3.3394:3433](),[3.3433][3.1899:1992]()
    ```
    run killall.js grow.js hack.js
    ```
    Kills all `grow.js` and `hack.js` scripts on any servers that they are currently running on.
    [3.3394]
    [3.1992]
    ---
  • replacement in README.md at line 113
    [3.1993][3.3137:3301]()
    ```
    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.
    [3.1993]
    [3.3873767]
    ## 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.
  • replacement in README.md at line 116
    [3.3873768][3.3302:3315](),[3.3315][3.2007:2132](),[3.3873768][3.2007:2132]()
    ## Debugging
    To enable debugging of `main.js`, set the `boolean_on` variable in the `void_debug` function in the `lib.js` file to `true`.
    [3.3873768]
    [3.2132]
    ---