added action cap. improved scoring system. fixed parts of security and cash predictors. made lshw loopable.

[?]
Apr 12, 2020, 11:54 PM
VMXI7PS4GFDOWPFLHQ7TYKJ5K3K7FXNPJCBEVYHTTRN7YB5ZHEQAC

Dependencies

  • [2] YANDOFZ4 added readme and licenses
  • [3] 6MBUKAG6 remove unneeded functions and comments. update readme.
  • [4] 3TYF4BJS target only hackable servers. replace servers continually.
  • [5] 2BKHJI2S init

Change contents

  • edit in sbin/weaken.js at line 3
    [4.1671][4.1671:1732]()
    // const start = Date.now();
    // const s = new Date(start);
  • edit in sbin/weaken.js at line 4
    [4.1763][4.1763:1997]()
    // const finish = Date.now();
    // const f = new Date(finish);
    // ns.tprint("\t#" + ns.args[3] + "\t" + ns.args[0] + " weakening " + ns.args[1] + "\nWeaken started:\t\t" + s.toISOString() + "\nWeaken finished:\t" + f.toISOString());
  • edit in sbin/hack.js at line 3
    [4.52603][4.52603:52664]()
    // const start = Date.now();
    // const s = new Date(start);
  • edit in sbin/hack.js at line 4
    [4.52693][4.52693:52923]()
    // const finish = Date.now();
    // const f = new Date(finish);
    // ns.tprint("\t#" + ns.args[3] + "\t" + ns.args[0] + " hacking " + ns.args[1] + "\nHack started:\t\t" + s.toISOString() + "\nHack finished:\t\t" + f.toISOString());
  • edit in sbin/grow.js at line 3
    [4.53031][4.53031:53092]()
    // const start = Date.now();
    // const s = new Date(start);
  • edit in sbin/grow.js at line 4
    [4.53121][4.53121:53351]()
    // const finish = Date.now();
    // const f = new Date(finish);
    // ns.tprint("\t#" + ns.args[3] + "\t" + ns.args[0] + " growing " + ns.args[1] + "\nGrow started:\t\t" + s.toISOString() + "\nGrow finished:\t\t" + f.toISOString());
  • replacement in lib/lib.js at line 12
    [4.3736612][4.3736612:3736717]()
    ns.tprint(`${new Date(Date.now()).toISOString()}: ${array_arguments[integer_indices_0].name}(`);
    [4.3736612]
    [4.3736717]
    ns.tprint(`${new Date().toISOString()}: ${array_arguments[integer_indices_0].name}(`);
  • replacement in lib/lib.js at line 168
    [4.3741221][4.3741221:3741319]()
    // object_constants are from https://github.com/danielyxie/bitburner/blob/master/src/Constants.js
    [4.3741221]
    [4.3741319]
    // object_constants are from https://github.com/danielyxie/bitburner/blob/master/src/Constants.js
  • replacement in lib/lib.js at line 230
    [4.3743342][4.1576:1617]()
    // name of current host (usually "home")
    [4.3743342]
    [4.3743384]
    // name of current host (usually "home")
  • replacement in lib/lib.js at line 355
    [4.2636][4.2636:2719]()
    if (// ram is at least equal to the minimum ram possible for purchased servers
    [4.2636]
    [4.2719]
    if (// you have no bought servers yet
    (ns.getPurchasedServers().length === 0) &&
    // ram is at least equal to the minimum ram possible for purchased servers
  • replacement in lib/lib.js at line 359
    [4.2809][4.2809:3192]()
    // ram is at least equal to the ram of "home", probably a bad idea to hardcode this since the string_name of "home" might change in the future. tags: warning, potential, problem
    (integer_server_ram_biggest_afforded >= integer_get_server_ram_total(ns, object_constants.string_host)) &&
    // you have no bought servers yet
    (ns.getPurchasedServers().length === 0)
    [4.2809]
    [4.3192]
    // ram is at least equal to the ram of "home" (probably a bad idea to hardcode this since the string_name of "home" might change in the future) or max ram.
    (integer_server_ram_biggest_afforded >= integer_get_server_ram_total(ns, "home") ||
    integer_server_ram_biggest_afforded >= object_constants.PurchasedServerMaxRam)
  • replacement in lib/lib.js at line 372
    [4.3407][4.3407:3495]()
    const integer_servers_bought_limit = object_get_constants(ns).PurchasedServerLimit;
    [4.3407]
    [4.3495]
    const object_constants = object_get_constants(ns);
  • replacement in lib/lib.js at line 377
    [4.3789][4.3789:3861]()
    (integer_servers_bought_amount < integer_servers_bought_limit) &&
    [4.3789]
    [4.3749897]
    (integer_servers_bought_amount < object_constants.PurchasedServerLimit) &&
  • replacement in lib/lib.js at line 379
    [4.3750019][4.3862:4023]()
    (float_ram_server_bought_biggest != integer_servers_bought_limit) &&
    (integer_get_server_ram_biggest_afforded(ns) > float_ram_server_bought_biggest)
    [4.3750019]
    [4.4023]
    (float_ram_server_bought_biggest != object_constants.PurchasedServerMaxRam) &&
    (float_ram_server_bought_biggest < integer_get_server_ram_biggest_afforded(ns))
  • replacement in lib/lib.js at line 393
    [4.4377][4.4377:4555]()
    if (// you have one or more servers already
    (integer_servers_bought_amount > 0) &&
    // you currently own less than the maximum amount of purchased servers allowed
    [4.4377]
    [4.4555]
    if (// you currently own less than the maximum amount of purchased servers allowed
  • replacement in lib/lib.js at line 397
    [4.4754][4.4754:4841]()
    (integer_get_server_ram_biggest_afforded(ns) == float_ram_server_bought_maximum)
    [4.4754]
    [4.4841]
    (integer_get_server_ram_biggest_afforded(ns) >= float_ram_server_bought_maximum)
  • edit in lib/lib.js at line 461
    [4.3753190]
    [4.3753190]
    ns.tprint(JSON.stringify(error));
  • edit in lib/lib.js at line 476
    [4.3755326]
    [4.3755326]
    ns.tprint(JSON.stringify(error));
  • replacement in lib/lib.js at line 490
    [4.3755736][4.3755736:3755879]()
    // returns the score of a server which is calculated by taking into account its max cash, growth, minimum security level and server difficulty
    [4.3755736]
    [4.3755879]
    // returns the score of a server which is calculated by taking into account its max cash, growth, and required hacking level. adapted from `calculatePercentMoneyHacked` in Hacking.js
  • replacement in lib/lib.js at line 493
    [4.3756004][4.3756004:3756238]()
    return ns.getServerMaxMoney(string_server_target) * ns.getServerGrowth(string_server_target) * Math.pow(ns.getServerMinSecurityLevel(string_server_target), -1) * Math.pow(ns.getServerRequiredHackingLevel(string_server_target), -1);
    [4.3756004]
    [4.3756238]
    const float_player_hacking_level = ns.getHackingLevel();
    return ns.getServerMaxMoney(string_server_target) * ns.getServerGrowth(string_server_target) * ((float_player_hacking_level - (ns.getServerRequiredHackingLevel(string_server_target) - 1)) * Math.pow(float_player_hacking_level, -1));
  • edit in lib/lib.js at line 601
    [4.3763872]
    [4.3763872]
    };
    // returns the security increase from the growth threads used. Adapted from `processSingleServerGrowth` in ServerHelpers.ts and `fortify` in Server.ts
    const float_get_security_increase_from_grow = function(ns, integer_threads_grow) {
    void_debug(float_get_security_increase_from_grow, Array.from(arguments));
    return 2 * object_get_constants(ns).ServerFortifyAmount * integer_threads_grow;
  • replacement in lib/lib.js at line 618
    [4.3764621][4.3764621:3765008]()
    const skillMult = (object_constants.object_stats.hacking - (ns.getServerRequiredHackingLevel(string_server_target) - 1)) / object_constants.object_stats.hacking;
    let percentMoneyHacked = difficultyMult * skillMult * object_constants.object_hacking_multipliers.money / balanceFactor;
    if (percentMoneyHacked < 0) {
    return 0;
    }
    if (percentMoneyHacked > 1) {
    return 1;
    }
    [4.3764621]
    [4.3765008]
    const skillMult = (ns.getHackingLevel() - (ns.getServerRequiredHackingLevel(string_server_target) - 1)) / ns.getHackingLevel();
    const percentMoneyHacked = difficultyMult * skillMult * object_constants.object_hacking_multipliers.money / balanceFactor;
    if (percentMoneyHacked < 0) { return 0; }
    if (percentMoneyHacked > 1) { return 1; }
  • replacement in lib/lib.js at line 629
    [4.3765447][4.3765447:3765594]()
    return float_percentage_to_steal / float_get_percentage_of_cash_from_available_per_hack(ns, string_server_target, float_server_target_security);
    [4.3765447]
    [4.3765594]
    return Math.ceil(float_percentage_to_steal / float_get_percentage_of_cash_from_available_per_hack(ns, string_server_target, float_server_target_security));
  • edit in lib/lib.js at line 638
    [4.3766396]
    [4.3766396]
    };
    // returns the security increase from the hack threads. adapted from `hack` in NetscriptFunctions.js and `fortify` in Server.ts
    const float_get_security_increase_from_hack = function(ns, string_server_target, float_server_target_security, float_server_target_cash, integer_threads_hack) {
    void_debug(float_get_security_increase_from_hack, Array.from(arguments));
    let maxThreadNeeded = Math.ceil(1/float_get_percentage_of_cash_from_available_per_hack(ns, string_server_target, float_server_target_security)*(float_server_target_cash/ns.getServerMaxMoney(string_server_target)));
    if (isNaN(maxThreadNeeded)) {
    // Server has a 'max money' of 0 (probably). We'll set this to an arbitrarily large value
    maxThreadNeeded = 1e6;
    }
    return object_get_constants(ns).ServerFortifyAmount * Math.min(integer_threads_hack, maxThreadNeeded);
  • replacement in lib/lib.js at line 661
    [4.3767061][4.3767061:3767546]()
    // returns true if there is enough ram to provide the threads required by grow to grow string_server_target's cash by float_percentage_to_steal if possible, otherwise, returns false. assumes security is at float_server_target_security
    const bool_is_ram_enough_for_growth_percentage = function(ns, float_server_used_ram_free, string_server_target, float_percentage_to_steal, float_server_target_security) {
    void_debug(bool_is_ram_enough_for_growth_percentage, Array.from(arguments));
    [4.3767061]
    [4.3767546]
    // returns true if there is enough ram to provide the threads required by weaken to weaken to minimum security, then by grow to grow string_server_target's cash by float_percentage_to_steal, then by weaken to weaken to minimum security again if possible, otherwise, returns false. assumes security is at float_server_target_security
    const bool_is_ram_enough_after_hack_percentage = function(ns, float_server_used_ram_free, string_server_target, float_server_target_cash_before, float_server_target_security, float_percentage_to_steal) {
    void_debug(bool_is_ram_enough_after_hack_percentage, Array.from(arguments));
  • replacement in lib/lib.js at line 666
    [4.3767688][4.3767688:3767874]()
    const integer_threads_required = integer_get_threads_required_for_cash_grow_after_percentage_stolen(ns, string_server_target, float_server_target_security, float_percentage_to_steal);
    [4.3767688]
    [4.3767874]
    const integer_threads_required = integer_get_threads_required_for_min_security_weaken(ns, string_server_target, float_get_security_increase_from_hack(ns, string_server_target, float_server_target_security, float_server_target_cash_before, integer_get_threads_hack(ns, float_server_used_ram_free, string_server_target, float_server_target_security, float_percentage_to_steal))) + integer_get_threads_required_for_cash_grow_after_percentage_stolen(ns, string_server_target, float_server_target_security, float_percentage_to_steal) + integer_get_threads_required_for_min_security_weaken(ns, string_server_target, float_get_security_increase_from_grow(ns, integer_get_threads_required_for_cash_grow_after_percentage_stolen(ns, string_server_target, float_server_target_security, float_percentage_to_steal)));
  • replacement in lib/lib.js at line 681
    [4.3768381][3.1741:1980](),[3.1980][4.3768609:3768770](),[4.3768609][4.3768609:3768770]()
    // 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
    const float_get_percentage_to_steal = function(ns, float_server_used_ram_free, string_server_target, float_server_target_security, float_precision, float_cap) {
    [4.3768381]
    [4.3768770]
    // this should return optimum percentage to steal such that cash stolen is as high as float_steal_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
    const float_get_percentage_to_steal = function(ns, float_server_used_ram_free, string_server_target, float_server_target_cash_before, float_server_target_security, float_precision, float_steal_cap) {
  • edit in lib/lib.js at line 684
    [4.3768838][3.1981:2184]()
    // 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 688
    [3.2327][3.2327:2497]()
    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)) {
    [3.2327]
    [4.3769268]
    if (bool_is_ram_enough_after_hack_percentage(ns, float_server_used_ram_free, string_server_target, float_server_target_cash_before, float_server_target_security, float_percentage_to_steal)) {
  • replacement in lib/lib.js at line 697
    [4.3769581][4.3769581:3769650]()
    if (float_percentage_to_steal > float_cap) {
    return float_cap;
    [4.3769581]
    [4.3769650]
    if (float_percentage_to_steal > float_steal_cap) {
    return float_steal_cap;
  • edit in lib/lib.js at line 736
    [4.6224]
    [4.6224]
    // iterate through array in reverse
  • replacement in lib/lib.js at line 771
    [4.3772600][4.3772600:3772706]()
    const float_get_time_hack = function(ns, string_server_target, float_server_target_security, hack, int) {
    [4.3772600]
    [4.3772706]
    const float_get_time_hack = function(ns, string_server_target, float_server_target_security) {
  • replacement in lib/lib.js at line 780
    [4.3773045][4.3773045:3773184]()
    if (hack == null) {hack = object_constants.object_stats.hacking;}
    if (int == null) {int = object_constants.object_stats.intelligence;}
    [4.3773045]
    [4.3773184]
    const hack = object_constants.object_stats.hacking;
    const int = object_constants.object_stats.intelligence;
  • replacement in lib/lib.js at line 793
    [4.3773627][4.3773627:3773733]()
    const float_get_time_grow = function(ns, string_server_target, float_server_target_security, hack, int) {
    [4.3773627]
    [4.3773733]
    const float_get_time_grow = function(ns, string_server_target, float_server_target_security) {
  • replacement in lib/lib.js at line 797
    [4.3773866][4.3773866:3773984]()
    return growTimeMultiplier * float_get_time_hack(ns, string_server_target, float_server_target_security, hack, int);
    [4.3773866]
    [4.3773984]
    return growTimeMultiplier * float_get_time_hack(ns, string_server_target, float_server_target_security);
  • replacement in lib/lib.js at line 801
    [4.3774119][4.3774119:3774227]()
    const float_get_time_weaken = function(ns, string_server_target, float_server_target_security, hack, int) {
    [4.3774119]
    [4.3774227]
    const float_get_time_weaken = function(ns, string_server_target, float_server_target_security) {
  • replacement in lib/lib.js at line 805
    [4.3774350][4.3774350:3774470]()
    return weakenTimeMultiplier * float_get_time_hack(ns, string_server_target, float_server_target_security, hack, int);
    [4.3774350]
    [4.3774470]
    return weakenTimeMultiplier * float_get_time_hack(ns, string_server_target, float_server_target_security);
  • replacement in lib/lib.js at line 808
    [4.3774474][3.2693:2787]()
    const array_make_schedule = function(ns, float_precision, float_cap, float_padding_seconds) {
    [4.3774474]
    [4.3774575]
    const array_make_schedule = function(ns, integer_action_cap, float_precision, float_steal_cap, float_padding_seconds) {
  • edit in lib/lib.js at line 824
    [4.3775684]
    [4.3775684]
    let integer_array_schedule_length = 0;
  • replacement in lib/lib.js at line 829
    [4.3775784][4.3775784:3775904]()
    for (let integer_indices_0 = 0; integer_indices_0 < array_servers_rooted_sorted_by_ram.length; ++integer_indices_0) {
    [4.3775784]
    [4.3775904]
    // iterate through servers in reverse to use servers with the biggest rams first
    for (let integer_indices_0 = array_servers_rooted_sorted_by_ram.length - 1; integer_indices_0 >= 0; --integer_indices_0) {
    if (integer_array_schedule_length >= integer_action_cap) {
    break;
    }
  • replacement in lib/lib.js at line 837
    [4.3776087][4.3776087:3776140]()
    while (float_server_used_ram_free_current > 0) {
    [4.3776087]
    [4.3776140]
    while (
    float_server_used_ram_free_current > 0 &&
    integer_array_schedule_length < integer_action_cap
    ) {
  • replacement in lib/lib.js at line 861
    [4.3777381][4.3777381:3777541]()
    let float_server_target_security_uncorrected = float_server_target_security_current - (integer_threads_weaken * object_constants.ServerWeakenAmount);
    [4.3777381]
    [4.3777541]
    const float_server_target_security_uncorrected = float_server_target_security_current - (integer_threads_weaken * object_constants.ServerWeakenAmount);
  • edit in lib/lib.js at line 877
    [4.3778717]
    [4.3778789]
    ++integer_array_schedule_length;
  • replacement in lib/lib.js at line 892
    [4.3779480][4.3779480:3779693]()
    let float_server_target_cash_current_uncorrected = float_server_target_cash_current * float_get_growth_from_threads(ns, string_server_target, float_server_target_security_current, integer_threads_grow);
    [4.3779480]
    [4.3779693]
    const float_server_target_cash_current_uncorrected = float_server_target_cash_current * float_get_growth_from_threads(ns, string_server_target, float_server_target_security_current, integer_threads_grow);
  • replacement in lib/lib.js at line 901
    [4.3780124][4.3780124:3780239]()
    float_server_target_security_current += 2 * object_constants.ServerFortifyAmount * integer_threads_grow;
    [4.3780124]
    [4.3780239]
    float_server_target_security_current += float_get_security_increase_from_grow(ns, integer_threads_grow);
  • edit in lib/lib.js at line 911
    [4.3781317]
    [4.3781387]
    ++integer_array_schedule_length;
  • replacement in lib/lib.js at line 922
    [4.3781781][4.3781781:3782106]()
    const integer_threads_hack = integer_get_threads_hack(ns, float_server_used_ram_free_current, string_server_target, float_server_target_security_current, float_get_percentage_to_steal (ns, float_server_used_ram_free_current, string_server_target, float_server_target_security_current, float_precision, float_cap));
    [4.3781781]
    [4.3782106]
    // this is supposed to be the section that uses the `float_get_percentage_to_steal` function to calculate and hack the optimum amount of cash, but it doesn't seem to work properly and I still haven't figured why or how to fix it, so for now I think it just hacks whatever `float_steal_cap` percent of cash the server has.
    //const integer_threads_hack = integer_get_threads_hack(ns, float_server_used_ram_free_current, string_server_target, float_server_target_security_current, float_get_percentage_to_steal(ns, float_server_used_ram_free_current, string_server_target, float_server_target_cash_current, float_server_target_security_current, float_precision, float_steal_cap));
  • replacement in lib/lib.js at line 925
    [4.3782107][4.3782107:3782203]()
    float_server_used_ram_free_current -= integer_threads_hack * object_scripts.hack.ram;
    [4.3782107]
    [4.3782203]
    const integer_threads_hack = integer_get_threads_hack(ns, float_server_used_ram_free_current, string_server_target, float_server_target_security_current, float_steal_cap);
  • replacement in lib/lib.js at line 927
    [4.3782204][4.3782204:3782403]()
    float_server_target_cash_current -= float_server_target_cash_current * float_get_percentage_of_cash_from_available_per_hack(ns, string_server_target, float_server_target_security_current);
    [4.3782204]
    [4.3782403]
    float_server_used_ram_free_current -= integer_threads_hack * object_scripts.hack.ram;
  • replacement in lib/lib.js at line 930
    [4.3782506][4.3782506:3782918]()
    let maxThreadNeeded = Math.ceil(1/float_get_percentage_of_cash_from_available_per_hack(ns, string_server_target, float_server_target_security_current)*(float_server_target_cash_current/float_server_target_cash_maximum));
    if (isNaN(maxThreadNeeded)) {
    // Server has a 'max money' of 0 (probably). We'll set this to an arbitrarily large value
    maxThreadNeeded = 1e6;
    [4.3782506]
    [4.3782918]
    const float_server_target_cash_before = float_server_target_cash_current;
    const float_server_target_cash_current_uncorrected = float_server_target_cash_current - Math.floor(float_server_target_cash_current * float_get_percentage_of_cash_from_available_per_hack(ns, string_server_target, float_server_target_security_current)) * integer_threads_hack;
    if (float_server_target_cash_current_uncorrected < 0) {
    float_server_target_cash_current = 0;
  • replacement in lib/lib.js at line 936
    [4.3782930][4.3782930:3783068]()
    float_server_target_security_current += object_constants.ServerFortifyAmount * Math.min(integer_threads_hack, maxThreadNeeded);
    [4.3782930]
    [4.3783068]
    else {
    float_server_target_cash_current = float_server_target_cash_current_uncorrected;
    }
    float_server_target_security_current += float_get_security_increase_from_hack(ns, string_server_target, float_server_target_security_current, float_server_target_cash_before, integer_threads_hack);
  • edit in lib/lib.js at line 950
    [4.3784146]
    [4.3784216]
    ++integer_array_schedule_length;
  • edit in lib/lib.js at line 956
    [4.3784261]
    [4.3784354]
    return array_schedule;
  • replacement in lib/lib.js at line 983
    [4.3785593][4.3785593:3785729]()
    export const void_schedule_runner = async function(ns, string_servers_bought_name, float_precision, float_cap, float_padding_seconds) {
    [4.3785593]
    [4.3785729]
    export const void_schedule_runner = async function(ns, string_servers_bought_name, integer_action_cap, float_precision, float_steal_cap, float_padding_seconds) {
  • replacement in lib/lib.js at line 998
    [3.2824][4.3786630:3786731](),[4.3786630][4.3786630:3786731]()
    const array_schedule = array_make_schedule(ns, float_precision, float_cap, float_padding_seconds);
    [3.2824]
    [4.3786731]
    const array_schedule = array_make_schedule(ns, integer_action_cap, float_precision, float_steal_cap, float_padding_seconds);
  • replacement in bin/main.js at line 7
    [4.3793822][4.3793822:3793864]()
    // variables
    // name of purchased servers
    [4.3793822]
    [2.1579]
    // variables
    // name of purchased servers
  • replacement in bin/main.js at line 10
    [2.1626][4.3793906:3793938](),[4.3793906][4.3793906:3793938]()
    // duration between each action
    [2.1626]
    [4.3793938]
    // maximum amount of actions to spawn per cycle, used to prevent using up too much IRL RAM
    const integer_action_cap = 200;
    // duration between each action
  • replacement in bin/main.js at line 14
    [4.3793975][4.3793975:3794026]()
    // precision of the percentage to steal calculator
    [4.3793975]
    [4.3794026]
    // precision of the percentage to steal calculator
  • replacement in bin/main.js at line 16
    [4.3794060][4.3794060:3794130](),[4.3794130][3.2828:2854](),[3.2854][4.3794156:3794209](),[4.3794156][4.3794156:3794209]()
    // the maximum percentage of cash that should be stolen from a server
    const float_cap = 0.98;
    // time period used for checking the time in seconds
    [4.3794060]
    [4.3794209]
    // the maximum percentage of cash that should be stolen from a server
    const float_steal_cap = 0.98;
    // time period used for checking the time in seconds
  • replacement in bin/main.js at line 21
    [4.3794251][4.3794251:3794264]()
    // main loop
    [4.3794251]
    [4.3794389]
    // main loop
  • replacement in bin/main.js at line 27
    [4.6837][4.3794733:3794887](),[4.3794733][4.3794733:3794887]()
    integer_time_finishes = await void_schedule_runner(ns, string_servers_bought_name, float_precision, float_cap, float_padding_seconds) + Date.now();
    [4.3794595]
    [4.3794956]
    integer_time_finishes = await void_schedule_runner(ns, string_servers_bought_name, integer_action_cap, float_precision, float_steal_cap, float_padding_seconds) + Date.now();
  • edit in bin/lshw.js at line 1
    [4.3795203]
    [4.3795204]
    const void_print_information = function (ns, string_server) {
    const float_cash_max = ns.getServerMaxMoney(string_server);
    const float_cash_current = ns.getServerMoneyAvailable(string_server);
    const float_security_minimum = ns.getServerMinSecurityLevel(string_server);
    const float_security_current = Math.round(ns.getServerSecurityLevel(string_server));
    const array_ram = ns.getServerRam(string_server);
    const float_ram_total = array_ram[0];
    const float_ram_used = array_ram[1];
    const float_ram_free = array_ram[0] - array_ram[1];
    const string_server_information =
    // comment out unneeded info
    `
    Time: ${new Date().toISOString()}
    Name: ${string_server}
    Root access: ${ns.hasRootAccess(string_server)}
    Maximum cash ($): ${float_cash_max}
    Current cash ($): ${float_cash_current.toFixed(2)}
    Current cash (%): ${(float_cash_current * 100 / float_cash_max).toFixed(2)}
    Minimum security: ${float_security_minimum}
    Current security: ${float_security_current}
    Current security (x): ${(float_security_current / float_security_minimum).toFixed(2)}
    Growth rate: ${ns.getServerGrowth(string_server)}
    Hacking level needed: ${ns.getServerRequiredHackingLevel(string_server)}
    Ports needed for root: ${ns.getServerNumPortsRequired(string_server)}
    RAM total (GB): ${float_ram_total}
    RAM used (GB): ${float_ram_used.toFixed(2)}
    RAM used (%): ${(float_ram_used * 100 / float_ram_total).toFixed(2)}
    RAM free (GB): ${float_ram_free.toFixed(2)}
    RAM free (%): ${(float_ram_free * 100 / float_ram_total).toFixed(2)}
    `;
    ns.tprint(string_server_information);
    };
  • replacement in bin/lshw.js at line 35
    [4.3795246][4.3795246:3797079]()
    for (let indices_0 = 0; indices_0 < ns.args.length; ++indices_0) {
    const float_cash_max = ns.getServerMaxMoney(ns.args[indices_0]);
    const float_cash_current = ns.getServerMoneyAvailable(ns.args[indices_0]);
    const float_security_minimum = ns.getServerMinSecurityLevel(ns.args[indices_0]);
    const float_security_current = Math.round(ns.getServerSecurityLevel(ns.args[indices_0]));
    const array_ram = ns.getServerRam(ns.args[indices_0]);
    const float_ram_total = array_ram[0];
    const float_ram_used = array_ram[1];
    const float_ram_free = array_ram[0] - array_ram[1];
    const data = [
    // comment out unneeded info
    "Name:\t\t\t" + ns.args[indices_0],
    "Root access:\t\t" + ns.hasRootAccess(ns.args[indices_0]),
    "Maximum cash ($):\t" + float_cash_max,
    "Current cash ($):\t" + float_cash_current.toFixed(2),
    "Current cash (%):\t" + (float_cash_current * 100 / float_cash_max).toFixed(2),
    "Growth:\t\t" + ns.getServerGrowth(ns.args[indices_0]),
    "Minimum security:\t" + float_security_minimum,
    "Current security:\t" + float_security_current,
    "Current security (x):\t" + (float_security_current / float_security_minimum).toFixed(2),
    "Hacking level needed:\t" + ns.getServerRequiredHackingLevel(ns.args[indices_0]),
    "Ports needed for root:\t" + ns.getServerNumPortsRequired(ns.args[indices_0]),
    "RAM total (Gb):\t" + float_ram_total,
    "RAM used (Gb):\t\t" + float_ram_used.toFixed(2),
    "RAM used (%):\t\t" + (float_ram_used * 100 / float_ram_total).toFixed(2),
    "RAM free (Gb):\t\t" + float_ram_free.toFixed(2),
    "RAM free (%):\t\t" + (float_ram_free * 100 / float_ram_total).toFixed(2),
    "\n"
    ];
    for (let indices_0 = 0; indices_0 < data.length; ++indices_0) {
    ns.tprint(data[indices_0]);
    }
    [4.3795246]
    [4.3797079]
    let array_arguments = ns.args;
    let float_sleep_duration = 0;
    while (true) {
    for (let integer_indices_0 = 0; integer_indices_0 < array_arguments.length; ++integer_indices_0) {
    const string_argument = array_arguments[integer_indices_0];
    if (
    (string_argument === "--sleep") ||
    (string_argument === "-s")
    ) {
    float_sleep_duration = array_arguments[integer_indices_0 + 1];
    array_arguments.splice(integer_indices_0, 2);
    }
    try {
    void_print_information(ns, string_argument);
    }
    catch (error) {
    ns.tprint(JSON.stringify(error));
    }
    }
    if (float_sleep_duration < 1) {
    break;
    }
    else {
    await ns.sleep(float_sleep_duration);
    }
  • replacement in README.md at line 20
    [3.3559][3.3559:3599]()
    ### `lshw.js <"SERVER1" ...>` (2.45 GB)
    [3.3559]
    [3.3599]
    ### `lshw.js [-s INTERVAL] <SERVER1 ...>` (2.45 GB)
  • edit in README.md at line 23
    [3.3651]
    [4.3873389]
    * Optionally, display the information at regular intervals. The INTERVAL parameter accepts a value >= 1 in milliseconds.
  • edit in README.md at line 31
    [3.3771]
    [3.3771]
    For scripts that don't take arguments:
  • replacement in README.md at line 35
    [3.3791][3.3791:3794]()
    or
    [3.3791]
    [3.3794]
    For scripts that take arguments:
  • replacement in README.md at line 38
    [3.3798][3.3798:3830]()
    run lshw.js "home" "foodnstuff"
    [3.3798]
    [3.3830]
    run lshw.js -s 1000 home foodnstuff
  • edit in README.md at line 40
    [3.3834]
    [4.3873767]
    The above will cause the terminal to output up-to-date information about the "home" "foodnstuff" servers every second.