fixed optimum percentage to steal calculator.
[?]
Apr 17, 2020, 10:44 PM
2LU5Y77OWHXI4FV3YKELPYQSUOQGRSO7CXWPKUCQZ2WM5YUBZBRQCDependencies
- [2]
BZ6FC2BTadd `cp.js`. - [3]
EYKBOK3Ooptimised the scheduling logic by ensuring that cycles start and finish at minimum security of target. - [4]
VHWFHMNW2nd attempt to fix percentage to steal - [5]
HHZNTFCTremove `-t` flag for `main.js` which conflicted with the same flag for the `run` command. - [6]
VMXI7PS4added action cap. improved scoring system. fixed parts of security and cash predictors. made lshw loopable. - [7]
YANDOFZ4added readme and licenses - [8]
2BKHJI2Sinit - [9]
6MBUKAG6remove unneeded functions and comments. update readme.
Change contents
- replacement in lib/lib.js at line 670
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));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
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);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
const integer_cycles_for_bisection_precision = integer_get_cycles_for_bisection_precision(ns, float_precision); - replacement in lib/lib.js at line 709
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)) {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
if (float_percentage_to_steal > float_steal_cap) {break;} - replacement in lib/lib.js at line 785
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));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
if (!bool_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.weaken.ram, 1)) {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
if (!bool_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.weaken.ram, 1)) {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
if (!bool_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.grow.ram, 1)) {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
if (!bool_can_server_run_script_threads(ns, float_server_used_ram_free_current, object_scripts.hack.ram, 1)) {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
// // 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
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);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
let array_schedule_edited = array_schedule; - replacement in lib/lib.js at line 1059
for (let integer_indices_1 = array_schedule.length - 1; integer_indices_1 >= 0; --integer_indices_1) {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
const object_job = array_schedule[integer_indices_1];const object_job = array_schedule_edited[integer_indices_1]; - replacement in lib/lib.js at line 1066
array_schedule.splice(integer_indices_1, 1);array_schedule_edited.splice(integer_indices_1, 1); - replacement in lib/lib.js at line 1070
array_schedule.splice(integer_indices_1, 1);array_schedule_edited.splice(integer_indices_1, 1); - replacement in lib/lib.js at line 1074
return array_schedule;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
// 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.// 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
const float_padding_seconds = 0.1;const float_padding_seconds = 0.4; - replacement in bin/main.js at line 18
const float_precision = 0.0001;const float_precision = 0.001; - replacement in bin/main.js at line 20
const float_steal_cap = 0.98;const float_steal_cap = 0.96;