Skip to content

Commit

Permalink
v.7.2.1. - Reduced data sent into zip
Browse files Browse the repository at this point in the history
  • Loading branch information
nayfaan committed Oct 28, 2023
1 parent c512541 commit 434dff4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
</span>
</div>

<div>Maximum types of items: <input type="number" id="max_type" min="1" max="6" value="2">
<div>Maximum types of items: <input type="number" id="max_type" min="1" max="6" value="6">
<span class="tooltip">(?)
<span class="tooltiptext">The maximum type of different items to be fed. Smaller number will calculate (drastically) faster, but might not generate result at all.</span>
</span>
Expand Down
13 changes: 1 addition & 12 deletions web/static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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]);
Expand Down
27 changes: 25 additions & 2 deletions web/static/zipPerm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 434dff4

Please sign in to comment.