fixed optimum percentage to steal calculator.

[?]
Apr 17, 2020, 10:44 PM
2LU5Y77OWHXI4FV3YKELPYQSUOQGRSO7CXWPKUCQZ2WM5YUBZBRQC

Dependencies

  • [2] BZ6FC2BT add `cp.js`.
  • [3] EYKBOK3O optimised the scheduling logic by ensuring that cycles start and finish at minimum security of target.
  • [4] VHWFHMNW 2nd attempt to fix percentage to steal
  • [5] HHZNTFCT remove `-t` flag for `main.js` which conflicted with the same flag for the `run` command.
  • [6] VMXI7PS4 added action cap. improved scoring system. fixed parts of security and cash predictors. made lshw loopable.
  • [7] YANDOFZ4 added readme and licenses
  • [8] 2BKHJI2S init
  • [9] 6MBUKAG6 remove unneeded functions and comments. update readme.

Change contents

  • replacement in lib/lib.js at line 670
    [4.3535][4.3535:3732](),[4.3732][4.5672:5751](),[4.5672][4.5672:5751]()
    const bool_is_ram_enough_after_hack_percentage = function(ns, float_server_used_ram_free, string_server_target, float_server_target_cash, float_server_target_security, float_percentage_to_steal) {
    void_debug(bool_is_ram_enough_after_hack_percentage, Array.from(arguments));
    [4.3535]
    [4.3733]
    const boolean_is_ram_enough_after_hack_percentage = function(ns, float_server_used_ram_free, string_server_target, float_server_target_cash, float_server_target_security, float_percentage_to_steal) {
    void_debug(boolean_is_ram_enough_after_hack_percentage, Array.from(arguments));
  • replacement in lib/lib.js at line 686
    [4.5184][4.5184:5499]()
    const float_ram_required = (integer_threads_required_for_weaken_minimum_security_after_hack * object_scripts.grow.weaken) + (integer_threads_required_for_cash_grow_after_percentage_stolen * object_scripts.grow.ram) + (integer_threads_required_for_weaken_minimum_security_after_grow * object_scripts.grow.weaken);
    [4.5184]
    [4.5499]
    const float_ram_required = (integer_threads_required_for_weaken_minimum_security_after_hack * object_scripts.weaken.ram) + (integer_threads_required_for_cash_grow_after_percentage_stolen * object_scripts.grow.ram) + (integer_threads_required_for_weaken_minimum_security_after_grow * object_scripts.weaken.ram);
  • edit in lib/lib.js at line 705
    [4.3768838]
    [4.3768838]
    const integer_cycles_for_bisection_precision = integer_get_cycles_for_bisection_precision(ns, float_precision);
  • replacement in lib/lib.js at line 709
    [4.3768957][4.2185:2327](),[4.2327][4.6203:6392]()
    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_after_hack_percentage(ns, float_server_used_ram_free, string_server_target, float_server_target_cash, float_server_target_security, float_percentage_to_steal)) {
    [4.3768957]
    [4.3769268]
    for (let integer_indices_0 = 0; integer_indices_0 < integer_cycles_for_bisection_precision; ++integer_indices_0) {
    if (boolean_is_ram_enough_after_hack_percentage(ns, float_server_used_ram_free, string_server_target, float_server_target_cash, float_server_target_security, float_percentage_to_steal)) {
  • edit in lib/lib.js at line 717
    [4.3769456]
    [4.3769456]
    if (float_percentage_to_steal > float_steal_cap) {
    break;
    }
  • replacement in lib/lib.js at line 785
    [4.3772157][4.3772157:3772351]()
    const bool_can_server_run_script_threads = function(ns, float_server_used_ram_free, float_script_ram, integer_threads) {
    void_debug(bool_can_server_run_script_threads, Array.from(arguments));
    [4.3772157]
    [4.3772351]
    const boolean_can_server_run_script_threads = function(ns, float_server_used_ram_free, float_script_ram, integer_threads) {
    void_debug(boolean_can_server_run_script_threads, Array.from(arguments));
  • replacement in lib/lib.js at line 873
    [3.3730][3.3730:3849]()
    if (!bool_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.weaken.ram, 1)) {
    [3.3730]
    [3.3849]
    if (!boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.weaken.ram, 1)) {
  • replacement in lib/lib.js at line 953
    [4.3776755][4.3776755:3776878]()
    if (!bool_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.weaken.ram, 1)) {
    [4.3776755]
    [4.3776878]
    if (!boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.weaken.ram, 1)) {
  • replacement in lib/lib.js at line 984
    [4.3778840][4.3778840:3778961]()
    if (!bool_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.grow.ram, 1)) {
    [4.3778840]
    [4.3778961]
    if (!boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.grow.ram, 1)) {
  • replacement in lib/lib.js at line 1018
    [4.3781438][4.3781438:3781559]()
    if (!bool_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.hack.ram, 1)) {
    [4.3781438]
    [4.3781559]
    if (!boolean_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.hack.ram, 1)) {
  • edit in lib/lib.js at line 1023
    [4.3781780][4.3781780:3781781](),[4.3781781][4.6561:7263]()
    // // 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 1024
    [4.3782107][4.9808:9990]()
    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);
    [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_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));
  • edit in lib/lib.js at line 1056
    [3.5752]
    [3.5752]
    let array_schedule_edited = array_schedule;
  • replacement in lib/lib.js at line 1059
    [3.5876][3.5876:5983]()
    for (let integer_indices_1 = array_schedule.length - 1; integer_indices_1 >= 0; --integer_indices_1) {
    [3.5876]
    [3.5983]
    for (let integer_indices_1 = array_schedule_edited.length - 1; integer_indices_1 >= 0; --integer_indices_1) {
  • replacement in lib/lib.js at line 1063
    [3.6078][3.6078:6138]()
    const object_job = array_schedule[integer_indices_1];
    [3.6078]
    [3.6138]
    const object_job = array_schedule_edited[integer_indices_1];
  • replacement in lib/lib.js at line 1066
    [3.6305][3.6305:6358]()
    array_schedule.splice(integer_indices_1, 1);
    [3.6305]
    [3.6358]
    array_schedule_edited.splice(integer_indices_1, 1);
  • replacement in lib/lib.js at line 1070
    [3.6394][3.6394:6447]()
    array_schedule.splice(integer_indices_1, 1);
    [3.6394]
    [3.6447]
    array_schedule_edited.splice(integer_indices_1, 1);
  • replacement in lib/lib.js at line 1074
    [3.6465][4.10963:10988](),[4.10963][4.10963:10988]()
    return array_schedule;
    [3.6465]
    [4.3784354]
    if (boolean_have_not_seen_item_with_security_minimum) {
    return array_schedule;
    }
    else {
    return array_schedule_edited;
    }
  • replacement in bin/main.js at line 1
    [4.3793719][2.2030:2481]()
    // TODO: Separate logic that can finish running (e.g. server buying logic which becomes redundant after 25 fully upgraded servers have been bought) to other sbins so that RAM usage is more efficient. Also separate logic that requires source files so that they are only ran when you have the required 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.
    [4.3793719]
    [2.2481]
    // TODO: Separate logic that can finish running (e.g. server buying logic which becomes redundant after 25 fully upgraded servers have been bought) to other sbins so that RAM usage is more efficient. Also separate logic that requires source files so that they are only ran when you have the required 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.
  • replacement in bin/main.js at line 16
    [4.3934][4.3934:3971]()
    const float_padding_seconds = 0.1;
    [4.3934]
    [4.11493]
    const float_padding_seconds = 0.4;
  • replacement in bin/main.js at line 18
    [4.11546][4.3794026:3794060](),[4.3794026][4.3794026:3794060]()
    const float_precision = 0.0001;
    [4.11546]
    [4.11547]
    const float_precision = 0.001;
  • replacement in bin/main.js at line 20
    [4.11619][4.11619:11651]()
    const float_steal_cap = 0.98;
    [4.11619]
    [4.11651]
    const float_steal_cap = 0.96;