diff --git a/index.html b/index.html index 1881c73..fb706c1 100644 --- a/index.html +++ b/index.html @@ -117,7 +117,7 @@ -
Maximum types of items: +
Maximum types of items: (?) The maximum type of different items to be fed. Smaller number will calculate (drastically) faster, but might not generate result at all. diff --git a/web/static/index.js b/web/static/index.js index 4f07b7a..7b9b049 100644 --- a/web/static/index.js +++ b/web/static/index.js @@ -216,18 +216,8 @@ function cross_item_category_rank(item_category_matrix, best_only) { for (let i in rank) { let rank_index = rank[i]; - let [score_0, score_1, score_2] = [0, 0, 0]; - for (let category of categories) { - let category_scores = value[category][0]; - let multiplier = value[category][1][rank_index]; - - score_0 += multiplier * category_scores[0]; - score_1 += multiplier * category_scores[1]; - score_2 += multiplier * category_scores[2]; - } - - let item_category_rank = [name, categories, rank_index, [score_0, score_1, score_2]]; + let item_category_rank = [name, categories, rank_index]; item_category_rank_matrix.push(item_category_rank); } } @@ -276,7 +266,6 @@ function puni_calc(settings) { let item_category_matrix = cross_item_category(craftable_only, best_only); let item_category_rank_matrix = cross_item_category_rank(item_category_matrix, best_only); - // console.log(item_category_matrix, item_category_rank_matrix) start_zip_worker(); w.postMessage([puni_target, ordered, item_category_rank_matrix, is_range, max_type, puni_target_min]); diff --git a/web/static/zipPerm.js b/web/static/zipPerm.js index 92a1c5a..db3f731 100644 --- a/web/static/zipPerm.js +++ b/web/static/zipPerm.js @@ -18,10 +18,32 @@ function clamp(min, num, max) { : num } +function calculate_score(categories, rank_index) { + let [score_0, score_1, score_2] = [0, 0, 0]; + + for (let category of categories) { + let category_scores = value[category][0]; + let multiplier = value[category][1][rank_index]; + + score_0 += multiplier * category_scores[0]; + score_1 += multiplier * category_scores[1]; + score_2 += multiplier * category_scores[2]; + } + + return [score_0, score_1, score_2] +} + function sum_score(feed_list) { let total = [20, 20, 20]; - for (let feed of feed_list) for (let i = 0; i < 3; i++) total[i] += feed[1] * feed[0][3][i]; + for (let feed of feed_list) { + [_, categories, rank_index] = feed[0]; + score_array = calculate_score(categories, rank_index) + + for (let i = 0; i < 3; i++) { + total[i] += feed[1] * score_array[i]; + } + } for (let i = 0; i < 3; i++) total[i] = clamp(0, total[i], 100); @@ -54,7 +76,8 @@ onmessage = function (e) { for (let i of itertoolsCombinations(item_category_rank_matrix, p.length)) { item_permutation.push(zip([i, p])); } - + console.log(p, item_permutation.length, JSON.stringify(item_permutation[0])) + for (item_combo of item_permutation) { success_match = false;