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AIT7UBAC export const main = async function (ns) {constfloat_period_check = 1e3 * ns.args[0],await ns.sleep(float_period_check);}for (;) {for (let integer_index_nodes = 0;integer_index_nodes < integer_nodes;++integer_index_nodes) {}}}await ns.sleep(float_period_check);}};if (object_upgrade.float_gain_rate_increase_cost_ratio >= float_minimum_ratio) {object_upgrade.void_upgrade();} else {break;}object_upgrade.float_gain_rate_increase_cost_ratio = float_ratio_cores;object_upgrade.void_upgrade = function () {ns.hacknet.upgradeCore(integer_index_nodes, 1);};if (float_ratio_cores > object_upgrade.float_gain_rate_increase_cost_ratio) {);object_upgrade.float_gain_rate_increase_cost_ratio = float_ratio_level;object_upgrade.void_upgrade = function () {ns.hacknet.upgradeLevel(integer_index_nodes, 1);};}object_upgrade.float_gain_rate_increase_cost_ratio = float_ratio_ram;object_upgrade.void_upgrade = function () {ns.hacknet.upgradeRam(integer_index_nodes, 1);};if (float_ratio_ram > object_upgrade.float_gain_rate_increase_cost_ratio) {if (float_ratio_level > object_upgrade.float_gain_rate_increase_cost_ratio) {constfloat_ratio_level = float_get_gain_rate_increase_cost_ratio(ns,integer_index_nodes,1,0,0),float_ratio_ram = float_get_gain_rate_increase_cost_ratio(ns,integer_index_nodes,0,1,0),float_ratio_cores = float_get_gain_rate_increase_cost_ratio(ns,integer_index_nodes,0,0,1constinteger_nodes = ns.hacknet.numNodes(),}};object_upgrade = {float_gain_rate_increase_cost_ratio: float_get_gain_rate(1,1,1) /ns.hacknet.getPurchaseNodeCost(),void_upgrade: function () {return ns.hacknet.purchaseNode();;for (;ns.hacknet.numNodes() <= 0;) {ns.hacknet.purchaseNode();float_minimum_ratio = ns.args[1];// Adapted from updateMoneyGainRate function in the src/Hacknet/HacknetNode.ts fileconst float_get_gain_rate = function (level,ram,cores) {return level * Math.pow(1.035, ram - 1) * (cores + 5);};ns,integer_node,level,ram,cores) {const object_node_stats = ns.hacknet.getNodeStats(integer_node););};return (float_get_gain_rate(object_node_stats.level + level,object_node_stats.ram + ram,object_node_stats.cores + cores) -float_get_gain_rate(object_node_stats.level,object_node_stats.ram,object_node_stats.cores)) /(ns.hacknet.getLevelUpgradeCost(integer_node,level) +ns.hacknet.getRamUpgradeCost(integer_node,ram) +ns.hacknet.getCoreUpgradeCost(integer_node,cores)const float_get_gain_rate_increase_cost_ratio = function (// hacknet.js - 5.6 GB - purchases nodes and upgrades them until the highest gain rate increase per cost ratio of the possible upgrades are below a given threshold.
],},{file: object_helpers.string_hack_net,threads_or_ram_botnet: 1,args: [float_period_check_seconds,float_gain_rate_increase_cost_ratio
((object_argument_names.hack_net.short === string_argument && argument_value) ||(object_argument_names.hack_net.long === string_argument && !argument_value)) &&array_helpers.splice(integer_get_index_of_file(array_helpers,object_helpers.string_hack_net),1),
-${object_argument_names.hack_net.short}, --no-${object_argument_names.hack_net.long}Prevents the "${object_helpers.string_hack_net}" script from being started which is responsible for buying and upgrading Hacknet nodes until the Hacknet node requirements for joining the Netburners faction are met.
FLOAT = The fraction of the botnet's current available RAM to be used by ${object_helpers.string_weaken_manager} to run threads of "${object_helpers.string_cyclic_weaken}". Should be a floating point number > 0. Defaults to ${object_defaults.float_ram_fraction_for_weaken_cyclic}.-${object_argument_names.hacknet_ratio.short}, --${object_argument_names.hacknet_ratio.long} <FLOAT>FLOAT = A value used in determining if "${object_helpers.string_hack_net}" should continue buying new Hacknet nodes/upgrades for these. Should be a floating point number >= 0. Higher values indicates a greater threshold so less upgrades/new nodes will be bought. Defaults to ${object_defaults.float_gain_rate_increase_cost_ratio}.`
FLOAT = The fraction of the botnet's current available RAM to be used by ${object_helpers.string_weaken_manager} to run threads of "${object_helpers.string_cyclic_weaken}". Should be a floating point number > 0. Defaults to ${object_defaults.float_ram_fraction_for_weaken_cyclic}.`
/* hacknet.js - 5.6 GB - purchases nodes and upgrades them until the highest gain rate increase per cost ratio of the possible upgrades are below a given threshold. TODO:* Link ratio to time to break-even*/import {string_sanitise,object_parse_arguments} from "lib_no_ns.js";const object_get_constants = function () {return {// default valuesobject_defaults: {// time period used for checking the time in secondsfloat_sleep_duration_seconds: 1,// minimum gain rate increase per cost ratio threshold before the script is killedfloat_minimum_ratio: 0.0005,},object_argument_names: {delay: {short: "d",long: "delay",},help: {short: "h",long: "help",},ratio: {short: "r",long: "ratio",},}};};const void_print_help = function (ns) {constobject_defaults = object_get_constants().object_defaults,object_argument_names = object_get_constants().object_argument_names;ns.tprint(string_sanitise(`DESCRIPTIONBuys Hacknet nodes and upgrades them until the highest gain rate increase per cost ratio of the possible upgrades are below a given threshold.USAGErun ${ns.getScriptName()} [FLAGS ...] [OPTIONS ...]FLAGS-${object_argument_names.help.short}, --${object_argument_names.help.long}Displays this message then exits.OPTIONS-${object_argument_names.delay.short}, --${object_argument_names.delay.long} <SECONDS>SECONDS = The duration of delay between each loop iteration, in seconds. Should be a floating-point number >= 0.001. Defaults to ${object_defaults.float_sleep_duration_seconds}.-${object_argument_names.ratio.short}, --${object_argument_names.ratio.long} <FLOAT>FLOAT = A value used in determining if the script should continue buying new Hacknet nodes/upgrades for these. Should be a floating point number >= 0. Higher values indicates a greater threshold so less upgrades/new nodes will be bought. Defaults to ${object_defaults.float_minimum_ratio}.`));};// Adapted from updateMoneyGainRate function in the src/Hacknet/HacknetNode.ts fileconst float_get_gain_rate = function (level,ram,cores) {return level * Math.pow(1.035, ram - 1) * (cores + 5);};const float_get_gain_rate_increase_cost_ratio = function (ns,integer_node,level,ram,cores) {const object_node_stats = ns.hacknet.getNodeStats(integer_node);return (float_get_gain_rate(object_node_stats.level + level,object_node_stats.ram + ram,object_node_stats.cores + cores) -float_get_gain_rate(object_node_stats.level,object_node_stats.ram,object_node_stats.cores)) /(ns.hacknet.getLevelUpgradeCost(integer_node,level) +ns.hacknet.getRamUpgradeCost(integer_node,ram) +ns.hacknet.getCoreUpgradeCost(integer_node,cores));};export const main = async function (ns) {// variablesconst// defaultsobject_defaults = object_get_constants().object_defaults,// argument namesobject_argument_names = object_get_constants().object_argument_names;letfloat_sleep_duration_seconds = object_defaults.float_sleep_duration_seconds,float_minimum_ratio = object_defaults.float_minimum_ratio,// whether to display help and exitboolean_print_help = !1;// argument parsingconst object_arguments = object_parse_arguments(ns.args);for (const string_argument in object_arguments)if (object_arguments.hasOwnProperty(string_argument)) {const argument_value = object_arguments[string_argument];switch (string_argument) {case object_argument_names.delay.short:// fall-throughcase object_argument_names.delay.long:float_sleep_duration_seconds = argument_value;break;case object_argument_names.help.short:// fall-throughcase object_argument_names.help.long:boolean_print_help = argument_value;break;case object_argument_names.ratio.short:// fall-throughcase object_argument_names.ratio.long:float_minimum_ratio = argument_value;break;case "_":continue;default:const string_message_error = `Unknown argument passed: "${string_argument}".`;throw (ns.tprint(`ERROR: ${string_message_error}`), new Error(string_message_error));}}// mainif (boolean_print_help)return void_print_help(ns);const float_period_check = 1e3 * float_sleep_duration_seconds;for (;ns.hacknet.numNodes() <= 0;) {if (ns.hacknet.purchaseNode() === -1) {await ns.sleep(float_period_check);}}for (;;) {constinteger_nodes = ns.hacknet.numNodes(),object_upgrade = {float_gain_rate_increase_cost_ratio: float_get_gain_rate(1,1,1) /ns.hacknet.getPurchaseNodeCost(),void_upgrade: function () {return ns.hacknet.purchaseNode();}};for (let integer_index_nodes = 0;integer_index_nodes < integer_nodes;++integer_index_nodes) {constfloat_ratio_level = float_get_gain_rate_increase_cost_ratio(ns,integer_index_nodes,1,0,0),float_ratio_ram = float_get_gain_rate_increase_cost_ratio(ns,integer_index_nodes,0,1,0),float_ratio_cores = float_get_gain_rate_increase_cost_ratio(ns,integer_index_nodes,0,0,1);if (float_ratio_level > object_upgrade.float_gain_rate_increase_cost_ratio) {object_upgrade.float_gain_rate_increase_cost_ratio = float_ratio_level;object_upgrade.void_upgrade = function () {ns.hacknet.upgradeLevel(integer_index_nodes, 1);};}if (float_ratio_ram > object_upgrade.float_gain_rate_increase_cost_ratio) {object_upgrade.float_gain_rate_increase_cost_ratio = float_ratio_ram;object_upgrade.void_upgrade = function () {ns.hacknet.upgradeRam(integer_index_nodes, 1);};}if (float_ratio_cores > object_upgrade.float_gain_rate_increase_cost_ratio) {object_upgrade.float_gain_rate_increase_cost_ratio = float_ratio_cores;object_upgrade.void_upgrade = function () {ns.hacknet.upgradeCore(integer_index_nodes, 1);};}}if (object_upgrade.float_gain_rate_increase_cost_ratio >= float_minimum_ratio) {object_upgrade.void_upgrade();} else {break;}await ns.sleep(float_period_check);}};
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.
Save all the `.js` files in this repository to the root directory of a rooted server (one with at least enough RAM to run "hacker.js", e.g. "foodnstuff") using the same filenames (but not including the directory names) that they currently have in this repository. If in the start of a new game, run `run botnet.js 0.001` (to increase the RAM available for the scripts) then `run kill.js` (to kill any currently running scripts).
* Run the helper scripts "ram.js"\* (6.6 GB), "servers.js" (8.85 GB), "tor.js"\* (3.8 GB), "programs.js"\* (3.7 GB), "botnet.js" (2.2 GB), "hacknet.js" (5.6 GB) and "weaken_manager.js" (4 GB) which should, respectively, attempt to:
* Run the helper scripts "ram.js"\* (6.6 GB), "servers.js" (8.85 GB), "tor.js"\* (3.8 GB), "programs.js"\* (3.7 GB), "botnet.js" (2.2 GB) and "weaken_manager.js" (4 GB) which should, respectively, attempt to:
`-w, --no-hacknet`* Prevents the "hacknet.js" script from being started which is responsible for buying and upgrading Hacknet nodes until the Hacknet node requirements for joining the Netburners faction are met.
`-x, --hacknet-ratio <FLOAT>`* FLOAT = A value used in determining if "hacknet.js" should continue buying new Hacknet nodes/upgrades for these. Should be a floating point number >= 0. Higher values indicates a greater threshold so less upgrades/new nodes will be bought. Defaults to 0.0005.
---### "hacknet.js" (5.6 GB)* Buys Hacknet nodes and upgrades them until the highest gain rate increase per cost ratio of the possible upgrades are below a given threshold.#### USAGE`run hacknet.js [FLAGS ...] [OPTIONS ...]`#### FLAGS`-h, --help`* Displays a help message then exits.#### OPTIONS`-d, --delay <SECONDS>`* SECONDS = The duration of delay between each loop iteration, in seconds. Should be a floating-point number >= 0.001. Defaults to 1.`-r, --ratio <FLOAT>`FLOAT = A value used in determining if the script should continue buying new Hacknet nodes/upgrades for these. Should be a floating point number >= 0. Higher values indicates a greater threshold so less upgrades/new nodes will be bought. Defaults to 0.0005.
* The duration of delay between each network-wide contract search and solve attempts, in seconds. Should be a floating-point number >= 0.001. By default, the script will only search for and attempt to solve contracts once, unless this option is manually set.
* SECONDS = The duration of delay between each network-wide contract search and solve attempts, in seconds. Should be a floating-point number >= 0.001. By default, the script will only search for and attempt to solve contracts once, unless this option is manually set.
---## Troubleshooting### "hacker.js" does not seem to run!* Make sure there is enough RAM (see requirements in the "Overview" section above) on the server that you ran "main.js" from and that there are no scripts running on that server before "hacker.js" has a chance to get spawned into it. Sometimes, "weaken_manager.js" will run "cyclic_weaken.js" on that server so you might need to kill any instances of it on that server before "hacker.js" is spawned.### I'm encountering "Invalid argument for thread count passed into exec()." or "Dynamic RAM usage calculated to be greater than initial RAM usage..." errors!* Sometimes the game doesn't calculate the RAM requirements of scripts properly which can occur if the scripts weren't saved properly through `nano` or were loaded into the game via other means. Try opening and resaving the scripts using `nano` to allow the game to properly calculate the scripts' RAM requirements.### I've followed the exact instructions above but I'm still encountering some other issue!* [Post about it in the repository's discussion page](https://nest.pijul.com/nicoty/bitburner_scripts/discussions) or contact me through Matrix (@nicoty:matrix.org) or Reddit (u/VoidNoire). Make sure your message contains the following information:* How you installed the scripts.* The exact command that you ran prior to encountering the issue.* The server from which you ran the command.* The amount of free RAM that the server has.* The outcome you expected.* The actual outcome that occurred instead (including exact error messages).### I want to ask some questions about how the scripts work/the game in general!* [See if this discussion about the hacking strategy used answers it](https://old.reddit.com/r/Bitburner/comments/g2ry1t/can_someone_explain_traditional_hacking_loop/). If not, feel free to contact me through one of the channels above.