3NFCZ6IPQPUCWANJN5WMUHUCHEQN7U5HZXMHDKVC6V6HXA3FG5YQC SLSWBNYTIFKBFLKXZTMONGDMEOHSOOCOSU4KVJCONZG2DK3BBIUQC 2BKHJI2SJ3VXTFBK2BWNN3I3BDNMUU5YTJGKTQCOXV66VVRHCGKAC YXH7ERRNAV2FHHAFREYBN7VJZZMGH3UJOXGM4IKS2USVKI543TFQC CJBGAILAK7G3WXYUBNUZMUMM3U5CPHWVK6ZAJWYBL4IOB5SZN32AC VMXI7PS4GFDOWPFLHQ7TYKJ5K3K7FXNPJCBEVYHTTRN7YB5ZHEQAC RWMZ7DVLOVPLR4FCIAVSABA5OESYUIEQ2OOZUYNPCNFEBYK5627AC NC66CZ5JPP3RPFCWAJE2ZBPFLA5ILKBNGTQLXDCRIUTIEWE74R4AC NQ22FUSWN6CBJKJ5H7UV5N2KEXBIXVNQDNL2EK6UJ3E7RFLWNVDQC // returns the total free RAM from all the servers you have root access toconst float_get_network_ram_free = function (ns) {
// returns the total RAM used from all the servers you have root access toconst float_get_network_ram_used = function (ns) {
// main.js - 8.75GB - TODO: Separate logic that requires source files so that they are only ran when you have the required source file - need a cheap way to check if you have source file? Maybe make a cache script that saves runtime constants like max money of servers to a cache file to potentially reduce RAM usage further. Maybe add functionality that allows on-the-fly hot loading of settings from a file.
// main.js - 8.85GB - TODO: Separate logic that requires source files so that they are only ran when you have the required source file - need a cheap way to check if you have source file? Maybe make a cache script that saves runtime constants like max money of servers to a cache file to potentially reduce RAM usage further. Maybe add functionality that allows on-the-fly hot loading of settings from a file. Possibly split the helper script execution management to a different script?
// helper scriptsconst string_helper_file_ram = "ram.js";const integer_helper_threads_ram = 1;const array_helper_arguments_ram = [float_period_check_seconds, float_ram_utilisation_threshold];const string_helper_file_servers = "servers.js";const integer_helper_threads_servers = 1;const array_helper_arguments_servers = [float_period_check_seconds, string_servers_bought_name, float_ram_utilisation_threshold];
const string_helper_file_botnet = "botnet.js";const integer_helper_threads_botnet = 1;const array_helper_arguments_botnet = [float_period_check_seconds];let array_helpers = [{file: string_helper_file_ram,threads: integer_helper_threads_ram,args: array_helper_arguments_ram},{file: string_helper_file_servers,threads: integer_helper_threads_servers,args: array_helper_arguments_servers},{file: string_helper_file_botnet,threads: integer_helper_threads_botnet,args: [array_helper_arguments_botnet]}];
// returns the index of the scripts array which matches the filename inputconst integer_get_index_of_file = function(array_scripts, string_file) {for (let integer_indices_0 = 0; integer_indices_0 < array_scripts.length; ++integer_indices_0) {const object_script = array_scripts[integer_indices_0];const string_script_file = object_script.file;if (string_script_file === string_file) {return integer_indices_0;}}};
// flagscase "-a":// fall-throughcase "--no-ram":array_arguments.splice(0, 1);array_helpers.splice(integer_get_index_of_file(array_helpers, string_helper_file_ram), 1);break;case "-e":// fall-throughcase "--no-servers":array_arguments.splice(0, 1);array_helpers.splice(integer_get_index_of_file(array_helpers, string_helper_file_servers), 1);break;case "-b":// fall-throughcase "--no-botnet":array_arguments.splice(0, 1);array_helpers.splice(integer_get_index_of_file(array_helpers, string_helper_file_botnet), 1);break;// options
const array_scripts = [// // uncomment if you have source-file 4// {// file: "ram.js",// ram: 6.6,// threads: 1,// arguments: [float_period_check_seconds, float_ram_utilisation_threshold]// },{file: "servers.js",ram: 8.85,threads: 1,arguments: [float_period_check_seconds, string_servers_bought_name, float_ram_utilisation_threshold]},{file: "botnet.js",ram: 2.15,threads: 1,arguments: [float_period_check_seconds]}];await void_script_executor(ns, array_scripts);
await void_script_executor(ns, array_helpers);
object_scripts: {object_weaken_script: {file: "weaken.js",ram: 1.75},object_grow_script: {file: "grow.js",ram: 1.75},object_hack_script: {file: "hack.js",ram: 1.7}}
array_workers: ["weaken.js", "grow.js", "hack.js"]
const integer_threads_available = Math.trunc(float_server_used_ram_free / object_get_constants(ns).object_scripts.object_weaken_script.ram);
const string_weaken = object_get_constants(ns).array_workers[0];const integer_threads_available = Math.trunc(float_server_used_ram_free / ns.getScriptRam(string_weaken));
const integer_threads_available = Math.trunc(float_server_used_ram_free / object_get_constants(ns).object_scripts.object_grow_script.ram);
const string_grow = object_get_constants(ns).array_workers[1];const integer_threads_available = Math.trunc(float_server_used_ram_free / ns.getScriptRam(string_grow));
const integer_threads_available = Math.trunc(float_server_used_ram_free / object_get_constants(ns).object_scripts.object_hack_script.ram);
const string_hack = object_get_constants(ns).array_workers[2];const integer_threads_available = Math.trunc(float_server_used_ram_free / ns.getScriptRam(string_hack));
const float_ram_required = (integer_threads_required_for_weaken_minimum_security_after_hack * object_scripts.object_weaken_script.ram) + (integer_threads_required_for_cash_grow_after_percentage_stolen * object_scripts.object_grow_script.ram) + (integer_threads_required_for_weaken_minimum_security_after_grow * object_scripts.object_weaken_script.ram);
const float_ram_required = (integer_threads_required_for_weaken_minimum_security_after_hack * ns.getScriptRam(string_weaken)) + (integer_threads_required_for_cash_grow_after_percentage_stolen * ns.getScriptRam(string_weaken)) + (integer_threads_required_for_weaken_minimum_security_after_grow * ns.getScriptRam(string_grow));
const object_constants = object_get_constants(ns);const object_scripts = object_constants.object_scripts;
const array_workers = object_get_constants(ns).array_workers;const string_weaken = array_workers[0];const string_grow = array_workers[1];const string_hack = array_workers[2];
const object_constants = object_get_constants(ns);const object_scripts = object_constants.object_scripts;let string_server_target = string_server_target_argument;if (string_server_target_argument === "") {string_server_target = string_get_server_rooted_hackable_with_score_biggest(ns);}// copy scripts to rooted serversvoid_copy_files_to_string_servers_rooted(ns, [object_scripts.object_weaken_script.file,object_scripts.object_grow_script.file,object_scripts.object_hack_script.file], ns.getHostname());// prepare the target if necessarywhile (true) {if (ns.getServerSecurityLevel(string_server_target) === ns.getServerMinSecurityLevel(string_server_target) &&ns.getServerMoneyAvailable(string_server_target) === ns.getServerMaxMoney(string_server_target)) {break;}const array_schedule_prepare = array_make_schedule(ns, integer_job_cap, float_precision, float_steal_cap, float_padding_seconds, string_server_target, string_job_decider_prepare);if (array_schedule_prepare.length > 0) {await void_schedule_runner(ns, array_schedule_prepare);await ns.sleep(array_schedule_prepare[array_schedule_prepare.length - 1].integer_time_job_finishes_seconds * 1000);}}// make and run actual hacking scheduleconst array_schedule = array_make_schedule(ns, integer_job_cap, float_precision, float_steal_cap, float_padding_seconds, string_server_target, string_job_decider);await void_schedule_runner(ns, array_schedule);return array_schedule[array_schedule.length - 1].integer_time_job_finishes_seconds * 1000;};
================================};<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#### FLAGS`-a, --no-ram`* Prevents the "ram.js" script from being started which is responsible for upgrading the RAM of the "home" server.`-b, --no-botnet`* Prevents the "botnet.js" script from being started which is responsible for rooting servers in the network.`-e, --no-servers`* Prevents the "servers.js" script from being started which is responsible for the purchasing and replacement of servers.
* Runs the script with up to 4000 jobs, targetting "harakiri-sushi", only upgrading/replacing RAM and servers when at least 0.7 of your network's total RAM is being used, and stealing only up to 50% of harakiri-sushi's cash per "hack.js" job that finishes executing, whilst the remaining variables are set to defaults.
* 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, and stealing only up to 50% of harakiri-sushi's cash per "hack.js" job that finishes executing, whilst the remaining variables are set to defaults. The "ram.js" and "botnet.js" helper scripts are also prevented from starting.