From 2218c10d7767e84d8bae1bd7fca30dfdd9485499 Mon Sep 17 00:00:00 2001 From: Nathan Abel Date: Thu, 16 Apr 2020 16:00:38 +0100 Subject: [PATCH 1/3] Squashed commit of the following: commit 4d46f7cfbda7d1818c5c07d22dce160fc5893ff4 Author: Nathan Abel Date: Wed Apr 15 12:43:30 2020 -0400 Delete launch.json This is a vscode config file. I forgot to remove it :) commit 96341d0030224d612fbd9bd20ca7c82405f817a9 Author: Nathan Abel Date: Wed Apr 15 12:40:15 2020 -0400 Handle Missing Patterns commit 7d995d5695861f81b1500ea63cbd0233530c9dea Author: Nathan Abel Date: Wed Apr 15 12:27:29 2020 -0400 Line break added commit a0b5f13db7504e2d3793cab7527b84cbe2b192c4 Author: Nathan Abel Date: Wed Apr 15 12:25:33 2020 -0400 Merge results into one col commit 6576eb1a55cdb978aca73cb16547fd87a41477c2 Author: Nathan Abel Date: Wed Apr 15 12:13:44 2020 -0400 Fix Sorting and Add Category Row commit c9b257cf6f7487c271be5d3801399cc7cd92e67b Merge: 511ef3c 8f49882 Author: Nathan Abel Date: Wed Apr 15 12:11:04 2020 -0400 Merge branch 'master' of https://github.com/mikebryant/ac-nh-turnip-prices into category_total_chance commit 511ef3caad223a4da0cd7f6ce4e68c5d108cbadd Author: Nathan Abel Date: Mon Apr 13 11:49:58 2020 -0400 Fix it better :) commit fcb0429fa1711534ffe875b94fddfb54c33a75df Author: Nathan Abel Date: Mon Apr 13 11:42:45 2020 -0400 Fix sort function --- js/predictions.js | 20 +++++++++++++------- js/scripts.js | 11 ++++++++++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/js/predictions.js b/js/predictions.js index 0a280cc..9a50b9e 100644 --- a/js/predictions.js +++ b/js/predictions.js @@ -845,15 +845,21 @@ function analyze_possibilities(sell_prices, first_buy, previous_pattern) { poss.weekGuaranteedMinimum = Math.max(...weekMins); poss.weekMax = Math.max(...weekMaxes); } + category_totals = {} + for (let i of ["Fluctuating", "Decreasing", "Small spike", "Large spike"]) { + category_totals[i] = generated_possibilities + .filter(value => value.pattern_description == i) + .map(value => value.probability) + .reduce((previous, current) => previous + current, 0) + console.log(category_totals[i]) + } + + for (let pos of generated_possibilities) { + pos.category_total_probability = category_totals[pos.pattern_description] + } generated_possibilities.sort((a, b) => { - if (a.weekMax < b.weekMax) { - return 1; - } else if (a.weekMax > b.weekMax) { - return -1; - } else { - return 0; - } + return b.category_total_probability - a.category_total_probability }); global_min_max = []; diff --git a/js/scripts.js b/js/scripts.js index e13b254..e4812a7 100644 --- a/js/scripts.js +++ b/js/scripts.js @@ -256,9 +256,18 @@ const calculateOutput = function (data, first_buy, previous_pattern) { } let output_possibilities = ""; let analyzed_possibilities = analyze_possibilities(data, first_buy, previous_pattern); + previous_pattern_description = "" for (let poss of analyzed_possibilities) { var out_line = "" + poss.pattern_description + "" - out_line += `${Number.isFinite(poss.probability) ? ((poss.probability * 100).toPrecision(3) + '%') : '—'}`; + if (previous_pattern_description != poss.pattern_description) { + previous_pattern_description = poss.pattern_description + pattern_count = analyzed_possibilities + .filter(val => val.pattern_description == poss.pattern_description) + .length + percentage_display = percent => Number.isFinite(percent) ? ((percent * 100).toPrecision(3) + '%') : '—' + out_line += `${percentage_display(poss.category_total_probability)}
`; + out_line += Number.isFinite(poss.probability) ? `(${pattern_count} @ ${percentage_display(poss.probability)})` : ""; + } for (let day of poss.prices.slice(1)) { if (day.min !== day.max) { out_line += `${day.min} ${i18next.t("output.to")} ${day.max}`; From 4c2f738a6b61e5209997cbac4dad4ec6ead3f4b0 Mon Sep 17 00:00:00 2001 From: Mike Bryant Date: Thu, 16 Apr 2020 20:00:35 +0100 Subject: [PATCH 2/3] feat: Allow for row probabilities Also change to use number not description, to work with translations --- index.html | 1 + js/predictions.js | 12 ++++++------ js/scripts.js | 12 ++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index c64963f..af325bc 100644 --- a/index.html +++ b/index.html @@ -213,6 +213,7 @@ +
diff --git a/js/predictions.js b/js/predictions.js index 9a50b9e..a6d00d2 100644 --- a/js/predictions.js +++ b/js/predictions.js @@ -845,21 +845,21 @@ function analyze_possibilities(sell_prices, first_buy, previous_pattern) { poss.weekGuaranteedMinimum = Math.max(...weekMins); poss.weekMax = Math.max(...weekMaxes); } + category_totals = {} - for (let i of ["Fluctuating", "Decreasing", "Small spike", "Large spike"]) { + for (let i of [0, 1, 2, 3]) { category_totals[i] = generated_possibilities - .filter(value => value.pattern_description == i) + .filter(value => value.pattern_number == i) .map(value => value.probability) - .reduce((previous, current) => previous + current, 0) - console.log(category_totals[i]) + .reduce((previous, current) => previous + current, 0); } for (let pos of generated_possibilities) { - pos.category_total_probability = category_totals[pos.pattern_description] + pos.category_total_probability = category_totals[pos.pattern_number]; } generated_possibilities.sort((a, b) => { - return b.category_total_probability - a.category_total_probability + return b.category_total_probability - a.category_total_probability || b.probability - a.probability; }); global_min_max = []; diff --git a/js/scripts.js b/js/scripts.js index e4812a7..a60bc60 100644 --- a/js/scripts.js +++ b/js/scripts.js @@ -256,18 +256,18 @@ const calculateOutput = function (data, first_buy, previous_pattern) { } let output_possibilities = ""; let analyzed_possibilities = analyze_possibilities(data, first_buy, previous_pattern); - previous_pattern_description = "" + previous_pattern_number = "" for (let poss of analyzed_possibilities) { var out_line = "" + poss.pattern_description + "" - if (previous_pattern_description != poss.pattern_description) { - previous_pattern_description = poss.pattern_description + if (previous_pattern_number != poss.pattern_number) { + previous_pattern_number = poss.pattern_number pattern_count = analyzed_possibilities - .filter(val => val.pattern_description == poss.pattern_description) + .filter(val => val.pattern_number == poss.pattern_number) .length percentage_display = percent => Number.isFinite(percent) ? ((percent * 100).toPrecision(3) + '%') : '—' - out_line += `${percentage_display(poss.category_total_probability)}
`; - out_line += Number.isFinite(poss.probability) ? `(${pattern_count} @ ${percentage_display(poss.probability)})` : ""; + out_line += `${percentage_display(poss.category_total_probability)}`; } + out_line += `${percentage_display(poss.probability)}`; for (let day of poss.prices.slice(1)) { if (day.min !== day.max) { out_line += `${day.min} ${i18next.t("output.to")} ${day.max}`; From a68ba675a638c9a25854040119cbbd9e9b6e95f6 Mon Sep 17 00:00:00 2001 From: Mike Bryant Date: Sat, 18 Apr 2020 15:33:37 +0100 Subject: [PATCH 3/3] fix: Make Chance a colspan instead of duplicated labels --- index.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.html b/index.html index af325bc..a14990c 100644 --- a/index.html +++ b/index.html @@ -212,8 +212,7 @@ - - +