From 8741ffee388c0751bb2281e07d7d61105b6fe759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Mart=C3=ADn=20Barbero?= Date: Sun, 4 Jan 2026 01:48:22 +0100 Subject: [PATCH 1/5] fix oll number order in times box fix oll number order in times box --- scripts/algsinfo.js | 6 ++++++ scripts/timer.js | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/algsinfo.js b/scripts/algsinfo.js index fab7265..84d57a2 100755 --- a/scripts/algsinfo.js +++ b/scripts/algsinfo.js @@ -1,5 +1,7 @@ var selCases = []; +var algsOrder = []; + var algsGroups = { "All Edges Oriented Correctly" : [26, 27, 21, 22, 24, 25, 23], "T-Shapes" : [33, 45], @@ -17,6 +19,10 @@ var algsGroups = { "No Edges Flipped Correctly" : [1,2,3,4,18,19,17,20], }; +for (i in algsGroups) { + algsOrder = algsOrder.concat(algsGroups[i]); +} + var algsInfo = { 1: { "name": "Runway", diff --git a/scripts/timer.js b/scripts/timer.js index 5d08fc8..563767e 100755 --- a/scripts/timer.js +++ b/scripts/timer.js @@ -453,7 +453,10 @@ function displayStats() } var keys = Object.keys(resultsByCase); - keys.sort(); + keys.sort(function(a, b) { + //return parseInt(a) - parseInt(b); // old simple fix numerical order + return algsOrder.indexOf(a) - algsOrder.indexOf(b); // new algsinfo ordering + }); var s = ""; // allocate them inside times span From 178193d2d024a36b79bcb8e4ebf10f47aa5f13d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Mart=C3=ADn=20Barbero?= Date: Sun, 4 Jan 2026 01:06:08 +0100 Subject: [PATCH 2/5] Weighted random selection of cases Assign same probability to all selected cases. If selected case is solved faster than goal ms, divide its probability in half. Otherwise double it. --- scripts/algsinfo.js | 2 ++ scripts/saveload.js | 6 ++++++ scripts/timer.js | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) mode change 100755 => 100644 scripts/saveload.js mode change 100755 => 100644 scripts/timer.js diff --git a/scripts/algsinfo.js b/scripts/algsinfo.js index 84d57a2..f014fa4 100755 --- a/scripts/algsinfo.js +++ b/scripts/algsinfo.js @@ -2,6 +2,8 @@ var selCases = []; var algsOrder = []; +var selCasesWeights = []; + var algsGroups = { "All Edges Oriented Correctly" : [26, 27, 21, 22, 24, 25, 23], "T-Shapes" : [33, 45], diff --git a/scripts/saveload.js b/scripts/saveload.js old mode 100755 new mode 100644 index ad23ceb..3b062d4 --- a/scripts/saveload.js +++ b/scripts/saveload.js @@ -27,7 +27,13 @@ function loadLocal(name, defaultValue) { } } +function initializeSelCasesWeights() { + window.selCasesWeights = new Array(window.selCases.length).fill(1); +} + function saveSelection() { + // we re-initialize the weights on selection change (save) + initializeSelCasesWeights(); return saveLocal('ollSelection', JSON.stringify(window.selCases)); } diff --git a/scripts/timer.js b/scripts/timer.js old mode 100755 new mode 100644 index 563767e..92e2aa7 --- a/scripts/timer.js +++ b/scripts/timer.js @@ -29,6 +29,31 @@ function randomElement(arr) return arr[Math.floor(Math.random()*arr.length)]; } +// https://stackoverflow.com/a/55671924 +function randomWeightedElement(items, weights) { + var i; + var _w = weights.slice(); // don't want to modify the original weights + + for (i = 1; i < _w.length; i++) + _w[i] += _w[i - 1]; + + var random = Math.random() * _w[_w.length - 1]; + + for (i = 0; i < _w.length; i++) + if (_w[i] > random) + break; + + return items[i]; +} + +function updateSelectedWeights(ms) +{ + const goal = 5000; // TODO: expose alg time goal in UI () + const index = window.selCases.indexOf(window.lastCase); + if (ms > 5000) window.selCasesWeights[index] *= 2; + else window.selCasesWeights[index] /= 2; +} + function confirmUnsel(i) { if (confirm("Do you want to unselect this case?")) { var index = window.selCases.indexOf(i); @@ -62,7 +87,7 @@ function generateScramble() // get random case var caseNum = 0; if (recapArray.length == 0) { // train - caseNum = randomElement(window.selCases); + caseNum = randomWeightedElement(window.selCases, window.selCasesWeights); } else { // recap // select the case caseNum = randomElement(window.recapArray); @@ -348,7 +373,9 @@ function escapeHtml(text) { function appendStats() { // assuming the time can be grabbed from timer label, and the case - window.lastCase - window.timesArray.push(makeResultInstance()); + var mri = makeResultInstance(); + window.timesArray.push(mri); + updateSelectedWeights(mri.ms); displayStats(); } @@ -389,6 +416,7 @@ function confirmClear() { if (confirm("Are you sure you want to clear session?")) { window.timesArray = []; + initializeSelCasesWeights(); document.getElementById('infoHeader').innerHTML = ('') displayStats(); } From 5c0808d41bd97e71329d4616c51d4448c9da238d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Mart=C3=ADn=20Barbero?= Date: Sun, 4 Jan 2026 01:06:53 +0100 Subject: [PATCH 3/5] Show weights in times list --- scripts/timer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/timer.js b/scripts/timer.js index 92e2aa7..7a936c7 100644 --- a/scripts/timer.js +++ b/scripts/timer.js @@ -493,6 +493,7 @@ function displayStats() var timesString = ""; var meanForCase = 0.0; var i = 0; + timesString += "[weight: " + window.selCasesWeights[window.selCases.indexOf(parseInt(oll))] + "] "; for (; i < resultsByCase[oll].length; i++) { timesString += makeHtmlDisplayableTime(resultsByCase[oll][i]); From 9cf1e7a130f812c93665351ad84eb81bfe31a09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Mart=C3=ADn=20Barbero?= Date: Sun, 4 Jan 2026 16:50:03 +0100 Subject: [PATCH 4/5] expose goal in the UI --- index.html | 1 + scripts/timer.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) mode change 100755 => 100644 index.html diff --git a/index.html b/index.html old mode 100755 new mode 100644 index 0ccf3d9..5c050e5 --- a/index.html +++ b/index.html @@ -42,6 +42,7 @@ background , text , links + , goal (ms) (0 or empty to ignore dynamic weights)
Any questions/suggestions/bugs reports - post in this thread diff --git a/scripts/timer.js b/scripts/timer.js index 7a936c7..9e16ac3 100644 --- a/scripts/timer.js +++ b/scripts/timer.js @@ -4,6 +4,7 @@ if (timesArray == null) // todo fix when figure out why JSON.parse("[]") returns timesArray = []; var lastScramble = ""; var lastCase = 0; +var goal = 5000; displayStats(); // after loading @@ -48,9 +49,9 @@ function randomWeightedElement(items, weights) { function updateSelectedWeights(ms) { - const goal = 5000; // TODO: expose alg time goal in UI () + if (isNaN(window.goal) || window.goal == 0) return; const index = window.selCases.indexOf(window.lastCase); - if (ms > 5000) window.selCasesWeights[index] *= 2; + if (ms > window.goal) window.selCasesWeights[index] *= 2; else window.selCasesWeights[index] /= 2; } @@ -493,7 +494,8 @@ function displayStats() var timesString = ""; var meanForCase = 0.0; var i = 0; - timesString += "[weight: " + window.selCasesWeights[window.selCases.indexOf(parseInt(oll))] + "] "; + if (!isNaN(window.goal) && window.goal > 0) + timesString += "[weight: " + window.selCasesWeights[window.selCases.indexOf(parseInt(oll))] + "] "; for (; i < resultsByCase[oll].length; i++) { timesString += makeHtmlDisplayableTime(resultsByCase[oll][i]); @@ -602,6 +604,12 @@ function resetStyle(dark) { savestyle(); } +function applygoal() { + //window.goal = document.getElementById("goal_in").value; + window.goal = document.querySelector('#goal_in').valueAsNumber; + displayStats(); +} + // add key listeners to blur settings inputs var inputs = document.getElementsByClassName("settinginput"); Array.prototype.forEach.call(inputs, function(el) { From 9c14e80b9b6c7488806190a58cdcb322fbf4faf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Mart=C3=ADn=20Barbero?= Date: Sun, 11 Jan 2026 23:28:30 +0100 Subject: [PATCH 5/5] Deactivate alg weights as a default Deactivate weights as a default and explain how to use the feature. --- index.html | 2 +- scripts/timer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 5c050e5..ae4915c 100644 --- a/index.html +++ b/index.html @@ -42,7 +42,7 @@ background , text , links - , goal (ms) (0 or empty to ignore dynamic weights) + , goal (ms) (0 or empty to ignore dynamic weights)
Any questions/suggestions/bugs reports - post in this thread diff --git a/scripts/timer.js b/scripts/timer.js index 9e16ac3..89ccc2f 100644 --- a/scripts/timer.js +++ b/scripts/timer.js @@ -4,7 +4,7 @@ if (timesArray == null) // todo fix when figure out why JSON.parse("[]") returns timesArray = []; var lastScramble = ""; var lastCase = 0; -var goal = 5000; +var goal = 0; displayStats(); // after loading