add more options to `main.js`. update `README.md`.
[?]
Apr 19, 2020, 2:29 PM
NQ22FUSWN6CBJKJ5H7UV5N2KEXBIXVNQDNL2EK6UJ3E7RFLWNVDQCDependencies
- [2]
2LU5Y77Ofixed optimum percentage to steal calculator. - [3]
HHZNTFCTremove `-t` flag for `main.js` which conflicted with the same flag for the `run` command. - [4]
2BKHJI2Sinit - [5]
6MBUKAG6remove unneeded functions and comments. update readme. - [6]
CJBGAILAadd optional `--target` parameter for `main.js`. update `README.md`. - [7]
VMXI7PS4added action cap. improved scoring system. fixed parts of security and cash predictors. made lshw loopable. - [8]
FA3U4WUJmore `README.md` changes. - [9]
BZ6FC2BTadd `cp.js`. - [10]
YANDOFZ4added readme and licenses - [11]
VHWFHMNW2nd attempt to fix percentage to steal - [12]
3TYF4BJStarget only hackable servers. replace servers continually. - [13]
BCM3TZOSadded `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]
EYKBOK3Ooptimised 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
void_debug(object_get_constants, Array.from(arguments));// from BitNode/BitNodeMultipliers - edit in lib/lib.js at line 215
// void_debug(array_get_servers, Array.from(arguments)); - edit in lib/lib.js at line 229
void_debug(array_get_servers, Array.from(arguments)); - edit in lib/lib.js at line 244
void_debug(integer_get_server_ram_total, Array.from(arguments)); - edit in lib/lib.js at line 249
void_debug(float_get_server_ram_used, Array.from(arguments)); - edit in lib/lib.js at line 254
void_debug(float_get_server_ram_free, Array.from(arguments)); - edit in lib/lib.js at line 261
void_debug(boolean_servers_bought_all_max, Array.from(arguments)); - edit in lib/lib.js at line 275
void_debug(string_get_server_bought_smallest, Array.from(arguments)); - edit in lib/lib.js at line 292
void_debug(string_get_server_bought_biggest, Array.from(arguments)); - edit in lib/lib.js at line 309
void_debug(integer_get_server_ram_biggest_afforded, Array.from(arguments)); - edit in lib/lib.js at line 319
void_debug(void_server_buy_or_upgrade, Array.from(arguments)); - edit in lib/lib.js at line 407
void_debug(array_get_servers_unrooted, Array.from(arguments)); - edit in lib/lib.js at line 419
void_debug(void_open_ports_try, Array.from(arguments)); - edit in lib/lib.js at line 432
void_debug(void_open_ports_nuke_try, Array.from(arguments)); - edit in lib/lib.js at line 449
void_debug(void_sort_by_server_ram, Array.from(arguments)); - edit in lib/lib.js at line 454
void_debug(float_get_server_score, Array.from(arguments)); - edit in lib/lib.js at line 460
void_debug(void_sort_by_server_scores, Array.from(arguments)); - edit in lib/lib.js at line 468
void_debug(array_get_servers_rooted, Array.from(arguments)); - edit in lib/lib.js at line 480
void_debug(integer_get_corrected_threads, Array.from(arguments)); - edit in lib/lib.js at line 492
void_debug(integer_get_threads_required_for_weaken, Array.from(arguments)); - edit in lib/lib.js at line 498
void_debug(integer_get_threads_required_for_weaken_minimum_security, Array.from(arguments)); - edit in lib/lib.js at line 503
void_debug(integer_get_threads_weaken, Array.from(arguments)); - edit in lib/lib.js at line 510
void_debug(float_get_security_decrease_from_weaken, Array.from(arguments)); - edit in lib/lib.js at line 517
void_debug(integer_get_threads_for_growth, Array.from(arguments)); - edit in lib/lib.js at line 532
void_debug(integer_get_threads_for_growth, Array.from(arguments)); - edit in lib/lib.js at line 547
void_debug(integer_get_threads_required_for_grow_maximum_cash, Array.from(arguments)); - edit in lib/lib.js at line 552
void_debug(integer_get_threads_grow, Array.from(arguments)); - edit in lib/lib.js at line 559
void_debug(float_get_security_increase_from_grow, Array.from(arguments)); - edit in lib/lib.js at line 566
void_debug(float_get_percentage_of_cash_from_available_per_hack, Array.from(arguments)); - edit in lib/lib.js at line 580
void_debug(integer_get_threads_required_to_hack_percentage, Array.from(arguments)); - edit in lib/lib.js at line 585
void_debug(integer_get_threads_hack, Array.from(arguments)); - edit in lib/lib.js at line 592
void_debug(float_get_security_increase_from_hack, Array.from(arguments)); - edit in lib/lib.js at line 605
void_debug(integer_get_threads_required_for_cash_grow_after_percentage_stolen, Array.from(arguments)); - edit in lib/lib.js at line 610
void_debug(boolean_is_ram_enough_after_hack_percentage, Array.from(arguments)); - edit in lib/lib.js at line 636
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
void_debug(void_copy_files_to_string_servers_rooted, Array.from(arguments)); - edit in lib/lib.js at line 680
void_debug(array_get_servers_rooted_sorted_by_ram, Array.from(arguments)); - edit in lib/lib.js at line 686
void_debug(array_get_servers_rooted_sorted_by_score, Array.from(arguments)); - edit in lib/lib.js at line 692
void_debug(string_get_server_rooted_hackable_with_score_biggest, Array.from(arguments)); - edit in lib/lib.js at line 703
void_debug(string_job_decide, Array.from(arguments)); - edit in lib/lib.js at line 717
void_debug(boolean_can_server_run_script_threads, Array.from(arguments)); - edit in lib/lib.js at line 727
void_debug(float_get_time_hack, Array.from(arguments)); - edit in lib/lib.js at line 748
void_debug(float_get_time_grow, Array.from(arguments)); - edit in lib/lib.js at line 755
void_debug(float_get_time_weaken, Array.from(arguments)); - edit in lib/lib.js at line 762
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
void_debug(void_exec_script_weaken, Array.from(arguments)); - edit in lib/lib.js at line 1015
void_debug(void_exec_script_grow, Array.from(arguments)); - edit in lib/lib.js at line 1020
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
const string_servers_bought_name = "server";let string_servers_bought_name = "server"; - replacement in bin/main.js at line 14
const integer_job_cap = 4000;let integer_job_cap = 2000; - replacement in bin/main.js at line 16
const float_padding_seconds = 0.4;let float_padding_seconds = 0.4; - replacement in bin/main.js at line 18
const float_precision = 0.001;let float_precision = 0.001; - replacement in bin/main.js at line 20
const float_steal_cap = 0.96;let float_steal_cap = 0.96; - replacement in bin/main.js at line 22
const float_period_check_seconds = 10;let float_period_check_seconds = 10; - edit in bin/main.js at line 29
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
(string_argument === "--target")(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
(string_argument === "--sleep") ||(string_argument === "-s")(string_argument === "--delay") ||(string_argument === "-d") - edit in README.md at line 2
## DescriptionScripts 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
### `main.js [--target SERVER]` (15.70 GB)Scripts for the game [Bitburner](https://github.com/danielyxie/bitburner).---## OverviewHere'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
* Optionally, target the a named server instead of picking one by itself.#### 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
### `killall.js [SCRIPT1 [SCRIPT2 ...]]` (3.05 GB)* 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
### `lshw.js [-s INTERVAL] <SERVER1 [SERVER2 ...]>` (2.45 GB)#### 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
* Optionally, display the information at regular intervals. The INTERVAL parameter accepts a value >= 1 in milliseconds.* 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
### `cp.js <SUBSTRING1 [SUBSTRING2 ...]>` (2.65 GB)### `cp.js` (2.65 GB) - replacement in README.md at line 101
## InstallationSave all the `.js` files in this repository to the "home" server using the same filenames.#### USAGE`run cp.js <ARGUMENT [ARGUMENT ...]>` - replacement in README.md at line 104
## UsageHere are some usage examples and the effects that should follow:* ARGUMENT = Substring contained in the names of files to be copied to the current server. - replacement in README.md at line 106
```run main.js```Starts the main daemon script.#### 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.* 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
```run killall.js grow.js hack.js```Kills all `grow.js` and `hack.js` scripts on any servers that they are currently running on.--- - replacement in README.md at line 113
```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.## InstallationSave 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
## DebuggingTo enable debugging of `main.js`, set the `boolean_on` variable in the `void_debug` function in the `lib.js` file to `true`.---