lib_score.js: refactor. add two functions for score correction. remove unneeded arbitrary hard-coded multipliers.
[?]
Apr 29, 2020, 2:30 PM
G7YVCY6HM6W46JYZWU6HY4VO4SQCHBP73LW2RTI2LPNRQD2TNKCACDependencies
- [2]
2WOLGB42README.md: update. kill.js: fix argument parser. lshw.js: add `-p` option. increase information given. main.js: fix error message. set saner defaults. hacker.js: split some functions into "lib_time.js" and "lib_score.js". ram.js: fix. - [3]
IVSW4A6Plib_score.js: normalised scores against average instead of using arbitrary values. - [4]
BKG7YVUVmain.js, hacker.js, servers.js, ram.js: refactor. - [5]
2BKHJI2Sinit - [6]
DJDWBCCQadd missing "nop.js". killall.js: rename to kill.js. add `--script` and `--server` options. - [7]
NQ22FUSWadd more options to `main.js`. update `README.md`. - [8]
MKHG4OQBmake worker scripts and worker script executor time-aware.
Change contents
- replacement in lib/lib_score.js at line 32
const array_get_servers_trait = function (ns, array_servers, void_get_trait) {// score correction methodsconst float_get_standard_score = function (float_original, array_numbers) {constfloat_get_variance = function (array_numbers) {const float_mean = float_get_mean(array_numbers);let float_sum_squared_differences = 0;for (let integer_indices_0 = 0;integer_indices_0 < array_numbers.length;++integer_indices_0)float_sum_squared_differences += Math.pow(array_numbers[integer_indices_0] - float_mean,2);return float_sum_squared_differences / array_numbers.length;},float_get_standard_deviation = function (array_numbers) {return Math.sqrt(float_get_variance(array_numbers));};return ((float_original - float_get_mean(array_numbers)) /float_get_standard_deviation(array_numbers));};const float_get_mean_normalised_score = function (float_original,array_numbers) {return ((float_original - float_get_mean(array_numbers)) /(Math.max(...array_numbers) - Math.min(...array_numbers)));};// returns a corrected score using a chosen correction methodconst float_get_corrected_score = function (float_original, array_numbers, float_method_score_correction) {return float_method_score_correction(float_original, array_numbers);};const array_get_servers_trait = function (ns, array_servers, float_get_trait_score) { - replacement in lib/lib_score.js at line 80
array_servers_trait.push(void_get_trait(ns, array_servers[integer_indices_0]));array_servers_trait.push(float_get_trait_score(ns, array_servers[integer_indices_0])); - edit in lib/lib_score.js at line 82
};const float_get_servers_hackable_mean_trait = function (ns, void_get_trait) {return float_get_mean(array_get_servers_trait(ns, array_get_servers_hackable(ns), void_get_trait)); - replacement in lib/lib_score.js at line 84
// gives a score for how well you will be able to hack a server (how much cash you can take per hack and how long it takes) given your current hacking level and its required hacking level. adapted from various functions in Hacking.js// gives a score for how well you will be able to hack a server (how much cash you can take per hack, how long it takes and your chances of hacking it successfully) given your current hacking level and its required hacking level. adapted from various functions in Hacking.js - replacement in lib/lib_score.js at line 98
// returns the score of a server which is calculated by taking into account the deviation from mean of its max cash, its growth rate and your skill against it.// returns the score of a server which is calculated by taking into account its max cash, its growth rate and your skill against it as factors which are corrected and summed. - replacement in lib/lib_score.js at line 101
float_mean_skill_against = float_get_servers_hackable_mean_trait(// can change this to try different correction methodsfloat_method_score_correction = float_get_standard_score,float_get_score_factor = function (ns,string_server,float_method_score_correction,float_get_trait_score) {return float_get_corrected_score(float_get_trait_score(ns, string_server),array_get_servers_trait(ns,array_get_servers_hackable(ns),float_get_trait_score),float_method_score_correction);},float_factor_skill = float_get_score_factor( - edit in lib/lib_score.js at line 123
string_server,float_method_score_correction, - replacement in lib/lib_score.js at line 127
float_mean_server_cash_max = float_get_servers_hackable_mean_trait(float_factor_max_cash = float_get_score_factor( - edit in lib/lib_score.js at line 129
string_server,float_method_score_correction, - replacement in lib/lib_score.js at line 133
float_mean_server_growth = float_get_servers_hackable_mean_trait(float_factor_growth = float_get_score_factor( - edit in lib/lib_score.js at line 135
string_server,float_method_score_correction, - replacement in lib/lib_score.js at line 138[3.1915]→[3.1915:1922](∅→∅),[3.1922]→[4.3718128:3718153](∅→∅),[4.3718128]→[4.3718128:3718153](∅→∅),[4.3718153]→[3.1923:2035](∅→∅),[3.2035]→[4.3718278:3718306](∅→∅),[4.3718278]→[4.3718278:3718306](∅→∅),[4.3718306]→[3.2036:2145](∅→∅),[3.2145]→[4.3718426:3718452](∅→∅),[4.3718426]→[4.3718426:3718452](∅→∅),[4.3718452]→[3.2146:2249](∅→∅)
),float_factor_skill =(float_get_skill_against(ns, string_server) - float_mean_skill_against) /float_mean_skill_against,float_factor_max_cash =(ns.getServerMaxMoney(string_server) - float_mean_server_cash_max) /float_mean_server_cash_max,float_factor_growth =(ns.getServerGrowth(string_server) - float_mean_server_growth) /float_mean_server_growth;); - replacement in lib/lib_score.js at line 140
// Can adjust the weights of the variables. 1 = normal importance, > 1 = more importance, < 1 = less importance, 0 = not used, < 0 = negative effect.// can adjust the weights of the factors. 1 = factor has normal importance, > 1 = factor has more importance, < 1 = factor has less importance, 0 = factor is not used, < 0 = factor has negative effect. - replacement in bin/main.js at line 43[4.1917]→[4.3080:3111](∅→∅),[2.2181]→[4.3080:3111](∅→∅),[4.3080]→[4.3080:3111](∅→∅),[4.3111]→[2.2182:2215](∅→∅)
// duration between each joblet float_padding_seconds = 1;// duration between each job used to prevent collisions between them to keep them in sequencelet float_padding_seconds = 0.5; - replacement in README.md at line 35
* SECONDS = The duration of delay between each job, in seconds. Should be a floating-point number > 0. Defaults to 1.* SECONDS = The duration of delay between each job, in seconds. Should be a floating-point number > 0. Defaults to 0.5.