remove unneeded functions and comments. update readme.
[?]
Apr 11, 2020, 6:36 PM
6MBUKAG6VK6XXGRSER273IP2R35P3C5K3KOY4QVSZXEOYD3H4WRACDependencies
- [2]
3TYF4BJStarget only hackable servers. replace servers continually. - [3]
2BKHJI2Sinit - [4]
YANDOFZ4added readme and licenses
Change contents
- edit in lib/lib.js at line 1
// // debugging function that produces an output by running the function it is debugging. as such, should not be used on impure functions. NOT WORKING PROPERLY, CAUSES INFINITE LOOPS DUE TO RECURSION.// const void_debug_pure = function() {// const boolean_on = true;// 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(Date.now()).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])}, `);// }// if (integer_indices_0 === array_arguments[1].length - 1) {// ns.tprint(`${string_argument_type}: ${JSON.stringify(array_arguments[1][integer_indices_0])})`);// }// }// }// ns.tprint(`output: ${JSON.stringify(eval(array_arguments[0].name)(...array_arguments[1]))}`);// }// }; - edit in lib/lib.js at line 452
// // opens ports of a server using available object_exploits// const void_open_ports = function(ns, string_server_target) {// void_debug_impure(void_open_ports, Array.from(arguments));// const object_constants = object_get_constants(ns);// const object_exploits = object_constants.object_exploits;// for (const exploit in object_exploits) {// if (ns.fileExists(object_exploits[exploit].file, object_constants.string_host)) {// eval("ns." + object_exploits[exploit].function + "(\"" + string_server_target + "\")");// }// }// }; - edit in lib/lib.js at line 466
// // returns the amount of exploits present in the string_host// const integer_get_exploits_amount = function(ns) {// void_debug_pure(integer_get_exploits_amount, Array.from(arguments));// const object_constants = object_get_constants(ns);// const object_exploits = object_constants.object_exploits;// let integer_exploits_amount = 0;// for (const exploit in object_exploits) {// if (ns.fileExists(object_exploits[exploit].file, object_constants.string_host)) {// ++integer_exploits_amount;// }// }// return integer_exploits_amount;// };// // opens ports and nukes any unrooted servers if the player's hacking level is high enough to do so and the appropriate number of object_exploits are present// const void_open_ports_nuke = function(ns) {// void_debug_impure(void_open_ports_nuke, Array.from(arguments));// const array_servers_unrooted = array_get_servers_unrooted(ns);// for (let integer_indices_0 = 0; integer_indices_0 < array_servers_unrooted.length; ++integer_indices_0) {// const string_server_unrooted = array_servers_unrooted[integer_indices_0];// if (// (ns.getServerRequiredHackingLevel(string_server_unrooted) <= object_get_constants(ns).object_stats.hacking) &&// (ns.getServerNumPortsRequired(string_server_unrooted) <= integer_get_exploits_amount(ns))// ) {// void_open_ports(ns, string_server_unrooted);// ns.nuke(string_server_unrooted);// }// }// }; - edit in lib/lib.js at line 517
// // returns the sum of all free ram from all the servers you have root access to// const float_get_ram_free_total = function(ns) {// void_debug_pure(float_get_ram_free_total, Array.from(arguments));// const array_servers_rooted = array_get_servers_rooted(ns);// let float_free_ram_from_servers_rooted = 0.0;// for (let integer_indices_0 = 0; integer_indices_0 < array_servers_rooted.length; ++integer_indices_0) {// float_free_ram_from_servers_rooted += float_get_server_ram_free(ns, array_servers_rooted[integer_indices_0]);// }// return float_free_ram_from_servers_rooted;// };// // returns what percentage of ram_free_total the ram of a server is// const float_get_percentage_of_server_ram_free_from_ram_free_total = function(ns, string_server) {// void_debug_pure(float_get_percentage_of_server_ram_free_from_ram_free_total, Array.from(arguments));// return float_get_server_ram_free(ns, string_server) / float_get_ram_free_total(ns);// }; - replacement in lib/lib.js at line 657
const integer_get_cycles_for_bisection_float_precision = function(ns, float_precision) {void_debug(integer_get_cycles_for_bisection_float_precision, Array.from(arguments));const integer_get_cycles_for_bisection_precision = function(ns, float_precision) {void_debug(integer_get_cycles_for_bisection_precision, Array.from(arguments)); - replacement in lib/lib.js at line 662
// returns optimum percentage to steal such that cash stolen is as high as float_cap and string_server_target's cash still able to be grown to 100% after one grow with the ram it has available by using a binary search algorithm// this should return optimum percentage to steal such that cash stolen is as high as float_cap and string_server_target's cash still able to be grown to 100% after one grow with the ram it has remaining by using a binary search algorithm - edit in lib/lib.js at line 665
// use half for the hack and half for the growth? would also need to take into account that ram for weaken is also needed?const float_server_used_ram_free_halved = float_server_used_ram_free * 0.5; - replacement in lib/lib.js at line 670
for (let integer_indices_0 = 0; integer_indices_0 < integer_get_cycles_for_bisection_float_precision(ns, float_precision); ++integer_indices_0) {if (bool_is_ram_enough_for_growth_percentage(ns, float_server_used_ram_free, string_server_target, float_percentage_to_steal, float_server_target_security)) {for (let integer_indices_0 = 0; integer_indices_0 < integer_get_cycles_for_bisection_precision(ns, float_precision); ++integer_indices_0) {if (bool_is_ram_enough_for_growth_percentage(ns, float_server_used_ram_free_halved, string_server_target, float_percentage_to_steal, float_server_target_security)) { - edit in lib/lib.js at line 688
// copy stuff - replacement in lib/lib.js at line 694
// if (!ns.fileExists(array_files[integer_indices_1], array_servers_rooted[integer_indices_0])) {ns.scp(array_files[integer_indices_1], string_source, array_servers_rooted[integer_indices_0]);// }ns.scp(array_files[integer_indices_1], string_source, array_servers_rooted[integer_indices_0]); - edit in lib/lib.js at line 716
const string_get_server_rooted_with_ram_biggest = function(ns) {void_debug(string_get_server_rooted_with_ram_biggest, Array.from(arguments));const array_servers_rooted_sorted_by_ram = array_get_servers_rooted_sorted_by_ram(ns);return array_servers_rooted_sorted_by_ram[array_servers_rooted_sorted_by_ram.length - 1];};const string_get_server_rooted_with_score_biggest = function(ns) {void_debug(string_get_server_rooted_with_score_biggest, Array.from(arguments));const array_servers_rooted_sorted_by_score = array_get_servers_rooted_sorted_by_score(ns);return array_servers_rooted_sorted_by_score[array_servers_rooted_sorted_by_score.length - 1];}; - replacement in lib/lib.js at line 717
void_debug(string_get_server_rooted_with_score_biggest, Array.from(arguments));void_debug(string_get_server_rooted_hackable_with_score_biggest, Array.from(arguments)); - replacement in lib/lib.js at line 790
export const array_make_schedule = function(ns, float_precision, float_cap, float_padding_seconds) {const array_make_schedule = function(ns, float_precision, float_cap, float_padding_seconds) { - edit in lib/lib.js at line 820
float_server_used_ram_free_before: float_server_used_ram_free_current, - edit in lib/lib.js at line 849
schedule_item.float_ram_cost = integer_threads_weaken * object_scripts.weaken.ram;schedule_item.float_server_used_ram_free_after = float_server_used_ram_free_current;schedule_item.float_server_target_security_after = float_server_target_security_current;schedule_item.float_server_target_security_delta = float_server_target_security_current - schedule_item.float_server_target_security_before; - edit in lib/lib.js at line 851
// ns.tprint(`weaken item: ${JSON.stringify(schedule_item)}`); - edit in lib/lib.js at line 882
schedule_item.float_ram_cost = integer_threads_grow * object_scripts.grow.ram;schedule_item.float_server_used_ram_free_after = float_server_used_ram_free_current;schedule_item.float_server_target_security_after = float_server_target_security_current;schedule_item.float_server_target_security_delta = float_server_target_security_current - schedule_item.float_server_target_security_before;schedule_item.float_server_target_cash_after = float_server_target_cash_current;schedule_item.float_server_target_cash_delta = float_server_target_cash_current - schedule_item.float_server_target_cash_before; - edit in lib/lib.js at line 884
// ns.tprint(`grow item: ${JSON.stringify(schedule_item)}`); - edit in lib/lib.js at line 914
schedule_item.float_ram_cost = integer_threads_hack * object_scripts.hack.ram;schedule_item.float_server_used_ram_free_after = float_server_used_ram_free_current;schedule_item.float_server_target_security_after = float_server_target_security_current;schedule_item.float_server_target_security_delta = float_server_target_security_current - schedule_item.float_server_target_security_before;schedule_item.float_server_target_cash_after = float_server_target_cash_current;schedule_item.float_server_target_cash_delta = float_server_target_cash_current - schedule_item.float_server_target_cash_before; - edit in lib/lib.js at line 916
// ns.tprint(`hack item: ${JSON.stringify(schedule_item)}`); - edit in lib/lib.js at line 921
// ns.tprint(`array_schedule: ${JSON.stringify(array_schedule)}`);return array_schedule; - edit in lib/lib.js at line 952
- edit in lib/lib.js at line 953
- edit in lib/lib.js at line 955
// array of current servers in the game (including bought servers) to be used for the loop, sorted by ram, from lowest to highestconst array_servers_rooted_used = void_sort_by_server_ram(ns, array_get_servers_rooted(ns)); - replacement in lib/lib.js at line 960
], object_constants.string_host, array_servers_rooted_used);], object_constants.string_host); - replacement in bin/main.js at line 15
const float_cap = 0.99;const float_cap = 0.98; - edit in bin/main.js at line 20
// // debug stuff// array_make_schedule(ns, float_precision, float_cap, float_padding_seconds);// await ns.sleep(1); - edit in bin/main.js at line 25
// ns.tprint(`current value before: ${integer_time_current}`);// ns.tprint(`finishes value before: ${integer_time_finishes}`); - edit in bin/main.js at line 26
// ns.tprint(`finishes value after: ${integer_time_finishes}`); - edit in README.md at line 4
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 7
Scripts for the game [Bitburner](https://github.com/danielyxie/bitburner).### `main.js` (15.70 GB)* Buy and replace old servers whenever appropriate.* Try to exploit and root servers if possible.* Copy `weaken.js`, `grow.js` and `hack.js` scripts to other servers.* Make a schedule containing information about when, where and how many threads (among other information) each of the scripts should be executed with.* Execute the actions in the schedule.* Repeat.### `killall.js` (3.05 GB)* Kill all running scripts.### `lshw.js <"SERVER1" ...>` (2.45 GB)* Display information about one or more servers. - replacement in README.md at line 24
To try them out, simply save all the .js files to the "home" server (which needs to have at least 15.7 GB of free RAM), then enter `run main.js` in the terminal. If you don't have enough RAM on "home", you can also edit the `object_get_constants` function in `lib.js` such that the `string_host` property points to another server that you have rooted and which has >= 15.7 GB.## InstallationSave all the `.js` files in this repository to the "home" server using the same filenames.## Usage```run main.js```or```run lshw.js "home" "foodnstuff"```