minor refactoring.
[?]
Apr 25, 2020, 3:21 PM
7SRULDRFXA6ZZUEXRPCDO7NIUJDREKYI3ESUYTOXMSPVMORDJXIQCDependencies
- [2]
3NFCZ6IPfixed the ram utilisation logic. added flags to `main.js` that can prevent the execution of helpers. - [3]
RWMZ7DVLsplit and refactor various logics. update "README.md". - [4]
NC66CZ5Jrename certain variables that had the same names as ns functions to prevent the RAM checker from triggering. - [5]
2LU5Y77Ofixed optimum percentage to steal calculator. - [6]
BZ6FC2BTadd `cp.js`. - [7]
6MBUKAG6remove unneeded functions and comments. update readme. - [8]
YANDOFZ4added readme and licenses - [9]
2BKHJI2Sinit - [10]
3TYF4BJStarget only hackable servers. replace servers continually. - [11]
CJBGAILAadd optional `--target` parameter for `main.js`. update `README.md`. - [12]
NQ22FUSWadd more options to `main.js`. update `README.md`. - [13]
HHZNTFCTremove `-t` flag for `main.js` which conflicted with the same flag for the `run` command. - [14]
4ACCU75Nimprove and refactor scheduling logic. - [15]
YXH7ERRNfixed bug that prevented helper scripts running if the "home" server does not have RAM bigger than the rest of the rooted servers. - [16]
SLSWBNYTadded ram utilisation logic to `ram.js` and `servers.js`. split and refactored redundant code into separate library files. - [17]
VMXI7PS4added action cap. improved scoring system. fixed parts of security and cash predictors. made lshw loopable.
Change contents
- replacement in bin/main.js at line 1
// 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?/* main.js - 8.85GB - TODO:* add --help flag* 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.* add a job cap thing that prevents running more jobs if the first worker in a cycle finishes. add a thing to worker script that writes to a file (or to `window`) its identifier, when it started and when it finishes. add a padding optimiser that detects when tail collision occurs and increases padding each cycle if it does occur, and decreases it by half of how much it increases everytime no tail collision occurs* do we need to Add delay between each script execution?*/ - replacement in bin/main.js at line 32
let integer_job_cap = 2000;let integer_job_cap = 1000; - replacement in bin/main.js at line 34
let float_padding_seconds = 0.4;let float_padding_seconds = 1; - replacement in bin/main.js at line 38
let float_steal_cap = 0.96;let float_steal_cap = 0.9; - edit in bin/main.js at line 45
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - edit in bin/main.js at line 48
const integer_helper_threads_ram = 1;const array_helper_arguments_ram = [float_period_check_seconds, float_ram_utilisation_threshold]; - replacement in bin/main.js at line 49
const integer_helper_threads_servers = 1;const array_helper_arguments_servers = [float_period_check_seconds, string_servers_bought_name, float_ram_utilisation_threshold];================================ - edit in bin/main.js at line 51
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]}]; - replacement in bin/main.js at line 74
// 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;// 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; - replacement in bin/main.js at line 150[3.4152]→[3.3794389:3794482](∅→∅),[2.4798]→[3.3794389:3794482](∅→∅),[3.11722]→[3.3794389:3794482](∅→∅),[3.3794389]→[3.3794389:3794482](∅→∅)
let integer_time_current = Date.now();let integer_time_finishes = integer_time_current;let integer_time_finishes = Date.now(); - replacement in bin/main.js at line 152
integer_time_current = Date.now();if (integer_time_current >= integer_time_finishes) {if (integer_time_finishes <= Date.now()) { - edit in bin/main.js at line 530
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - replacement in bin/main.js at line 715
// assumes weaken takes longestlet integer_time_job_finishes_seconds = float_time_weaken;let integer_time_job_finishes_seconds = Math.max(float_time_weaken, float_time_grow, float_time_hack); - replacement in bin/main.js at line 915
================================let integer_time_start = Date.now();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_get_constants(ns).array_workers], 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) - integer_time_start + Date.now());}}// 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) - integer_time_start + Date.now(); - replacement in bin/lshw.js at line 44
float_sleep_duration = array_arguments[integer_indices_0 + 1];float_sleep_duration = array_arguments[integer_indices_0 + 1] * 1000; - replacement in README.md at line 106
`-d, --delay <MILLISECONDS>``-d, --delay <SECONDS>` - replacement in README.md at line 108
* MILLISECONDS = The duration of delay between update, in milliseconds. Should be a floating-point number >= 1. By default, the script will only display server information once, unless this option is manually set.* SECONDS = The duration of delay between update, in seconds. Should be a floating-point number >= 0.001. By default, the script will only display server information once, unless this option is manually set. - replacement in README.md at line 111
`run lshw.js -s 1000 home foodnstuff``run lshw.js -d 1 home foodnstuff`