Skip to content

Commit

Permalink
fix zbll case stats, add cfzb in reconstruct tool
Browse files Browse the repository at this point in the history
  • Loading branch information
cs0x7f committed Aug 29, 2024
1 parent fc01f71 commit 97d89a9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 72 deletions.
23 changes: 22 additions & 1 deletion src/js/lib/cubeutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,23 @@ var cubeutil = (function() {
return 0;
}

//return 6: nothing, 5: cross solved, 2~4: nth f2l solved, 1 eoll solved, 0: solved
function getCF3ZBProgress(param) {
if (solvedProgress(param, crossMask)) {
return 6;
} else if (solvedProgress(param, eollMask)) {
return 1 + Math.max(1,
solvedProgress(param, f2l1Mask) +
solvedProgress(param, f2l2Mask) +
solvedProgress(param, f2l3Mask) +
solvedProgress(param, f2l4Mask)
);
} else if (solvedProgress(param)) {
return 1;
}
return 0;
}

//return 2: nothing, 1: f2l solved, 0: solved
function getFPProgress(param) {
if (solvedProgress(param, f2lMask)) {
Expand Down Expand Up @@ -406,7 +423,7 @@ var cubeutil = (function() {
'PLL': [identPLL, scramble_333.getPLLImage, 0, 21, 0],
'OLL': [identOLL, scramble_333.getOLLImage, 1, 58, 1],
'COLL': [identCOLL, scramble_333.getCOLLImage.bind(null, 'D'), 0, 40, 1],
'ZBLL': [identCOLL, scramble_333.getZBLLImage, 0, 493, 1],
'ZBLL': [identZBLL, scramble_333.getZBLLImage, 0, 493, 0],
'CLL': [identC2CLL, scramble_222.getEGLLImage, 0, 40, 1]
};
return method ? identData[method] : identData;
Expand Down Expand Up @@ -454,6 +471,8 @@ var cubeutil = (function() {
return getProgressNAxis(facelet, getRouxProgress, 24);
case 'cf4o2p2':
return getProgressNAxis(facelet, getCF4O2P2Progress, 6);
case 'cf3zb':
return getProgressNAxis(facelet, getCF3ZBProgress, 6);
case 'n':
return getProgressNAxis(facelet, solvedProgress, 1);
}
Expand All @@ -471,6 +490,8 @@ var cubeutil = (function() {
return ['l6e', 'cmll', 'sb', 'fb'];
case 'cf4o2p2':
return ['pll', 'cpll', 'oll', 'eoll', 'f2l-4', 'f2l-3', 'f2l-2', 'f2l-1', 'cross'];
case 'cf3zb':
return ['zbll', 'zbf2l', 'f2l-3', 'f2l-2', 'f2l-1', 'cross'];
case 'n':
return ['solve'];
}
Expand Down
60 changes: 28 additions & 32 deletions src/js/stats/recons.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ var recons = execMain(function() {
isPercent ? Math.round(val[2] / sumSubt * 1000) / 10 + '%' : kernel.pretty(val[2]),
Math.round(val[3] * 10) / 10,
val[3] > 0 && val[1] + val[2] > 0 ? Math.round(val[3] / (val[1] + val[2]) * 10000 ) / 10 : 'N/A',
['oll', 'pll'].indexOf(val[0]) != -1 ? 'click' : ''
['oll', 'pll', 'zbll'].indexOf(val[0]) != -1 ? 'click' : ''
]));
}
var endTr = $('<tr>').append(tidx ? $('<td>').append(requestBack) : $('<td style="padding:0;">').append(rangeSelect),
Expand Down Expand Up @@ -388,7 +388,7 @@ var recons = execMain(function() {
}

function showCasesDialog(method) {
kernel.setProp('rcCaseMthd', method);
kernel.setProp('rcCaseMthd', (method == 'ZBLL' ? 'cf3zb_' : 'cf4op_') + method);
caseStat.execFunc(casesDialogContent);
var onCloseDialog = function () {
caseStat.execFunc();
Expand All @@ -403,7 +403,7 @@ var recons = execMain(function() {
return;
}
var target = $(e.target);
if (['oll', 'pll'].indexOf(target.text()) != -1) {
if (['oll', 'pll', 'zbll'].indexOf(target.text()) != -1) {
return showCasesDialog(target.text().toUpperCase());
}
if (!target.is('.click') || target.is('.exturl')) {
Expand Down Expand Up @@ -454,7 +454,7 @@ var recons = execMain(function() {
for (var i = 0; i < ranges.length; i++) {
rangeSelect.append('<option value="' + ranges[i] + '">' + ranges[i] + '</option>');
}
var methods = [['cf4op', 'cfop'], ['roux', 'roux']];
var methods = [['cf4op', 'cfop'], ['roux', 'roux'], ['cf3zb', 'cfzb']];
for (var i = 0; i < methods.length; i++) {
methodSelect.append('<option value="' + methods[i][0] + '">' + methods[i][1] + '</option>');
methodSelect.append('<option value="' + methods[i][0] + '%">' + methods[i][1] + '%</option>');
Expand All @@ -465,15 +465,10 @@ var recons = execMain(function() {

(function() {
stats.regUtil('recons', update);
stats.regExtraInfo('recons_n', function(times) {
return calcRecons(times, 'n');
});
stats.regExtraInfo('recons_cf4op', function(times) {
return calcRecons(times, 'cf4op');
});
stats.regExtraInfo('recons_roux', function(times) {
return calcRecons(times, 'roux');
});
stats.regExtraInfo('recons_n', (times) => calcRecons(times, 'n'));
stats.regExtraInfo('recons_cf4op', (times) => calcRecons(times, 'cf4op'));
stats.regExtraInfo('recons_roux', (times) => calcRecons(times, 'roux'));
stats.regExtraInfo('recons_cf3zb', (times) => calcRecons(times, 'cf3zb'));
stats.regExtraInfo('recons_cfop_ct',
substepMetric.bind(null, 'cf4op', [6, 0], [6, 2]),
['cross ' + STATS_TIME, kernel.pretty]);
Expand Down Expand Up @@ -529,9 +524,9 @@ var caseStat = execMain(function() {

var div = $('<div style="font-size:0.9em;">');
var table = $('<table class="table">');
var methodSelect = $('<select>');
var methodStepSelect = $('<select>');
var tableTh = $('<tr>').append(
$('<th>').attr('colspan', 2).css('padding', '0').append(methodSelect),
$('<th>').attr('colspan', 2).css('padding', '0').append(methodStepSelect),
$('<th>').addClass('click').attr('data-sort-column', 2).append('N'),
$('<th>').addClass('click').attr('data-sort-column', 5).append(titleStr[0]),
$('<th>').addClass('click').attr('data-sort-column', 6).append(titleStr[1]),
Expand All @@ -545,12 +540,13 @@ var caseStat = execMain(function() {
}
var nsolv = stats.getTimesStatsTable().timesLen;
var nrec = nsolv;
var method = methodSelect.val() || 'PLL';
var ident = cubeutil.getIdentData(method);
var methodStep = methodStepSelect.val() || 'cf4op_PLL';
var step = methodStep.split('_')[1];
var ident = cubeutil.getIdentData(step);
var nvalid = 0;
var caseCnts = [];
for (var s = nsolv - 1; s >= nsolv - nrec; s--) {
var caseData = stats.getExtraInfo('recons_cf4op_' + method, s);
var caseData = stats.getExtraInfo('recons_' + methodStep, s);
if (!caseData) {
continue;
}
Expand Down Expand Up @@ -626,16 +622,16 @@ var caseStat = execMain(function() {
row.push(img.attr('src'));
table.append(curTr);
}
methodSelect.unbind('change').change(procMethodChange);
methodStepSelect.unbind('change').change(procMethodChange);
if (nvalid == 0) {
tableTh.after('<tr><td colspan=7>' + TOOLS_RECONS_NODATA + '</td></tr>');
return [method, []];
return [step, []];
}
return [method, trdata];
return [step, trdata];
}

function procMethodChange(e) {
kernel.setProp('rcCaseMthd', methodSelect.val());
kernel.setProp('rcCaseMthd', methodStepSelect.val());
update();
}

Expand All @@ -659,18 +655,18 @@ var caseStat = execMain(function() {
return;
}
fdiv.empty().append(div.append(table));
methodSelect.val(kernel.getProp('rcCaseMthd', 'PLL'));
methodStepSelect.val(kernel.getProp('rcCaseMthd', 'cf4op_PLL'));
update();
}

var c;

function calcCaseExtra(method, time, idx) {
var rec = stats.getExtraInfo('recons_cf4op', idx);
function calcCaseExtra(method, step, time, idx) {
var rec = stats.getExtraInfo('recons_' + method, idx);
if (!rec) {
return;
}
var ident = cubeutil.getIdentData(method);
var ident = cubeutil.getIdentData(step);
var data = rec.data;
var sdata = data[ident[4]];
if (!sdata) {
Expand All @@ -687,11 +683,11 @@ var caseStat = execMain(function() {
tools.regTool('casestat', TOOLS_RECONS + '>' + 'cases', execFunc);
}
stats.regUtil('casestat', update);
var methods = ['PLL', 'OLL'];
for (var i = 0; i < methods.length; i++) {
methodSelect.append('<option value="' + methods[i] + '">' + methods[i] + '</option>');
stats.regExtraInfo('recons_cf4op_' + methods[i], calcCaseExtra.bind(null, methods[i]));
}
var steps = [['cf4op', 'PLL'], ['cf4op', 'OLL'], ['cf3zb', 'ZBLL']];
steps.forEach((step) => {
methodStepSelect.append(`<option value="${step[0]}_${step[1]}">${step[1]}</option>`);
stats.regExtraInfo(`recons_${step[0]}_${step[1]}`, calcCaseExtra.bind(null, step[0], step[1]));
});
});

return {
Expand Down Expand Up @@ -906,7 +902,7 @@ var scatter = execMain(function() {
}
stats.regUtil('scatter', updateScatter);
kernel.regListener('scatter', 'reqrec', reqRecons);
var methods = [['cf4op', 'cfop'], ['roux', 'roux']];
var methods = [['cf4op', 'cfop'], ['roux', 'roux'], ['cf3zb', 'cfzb']];
for (var i = 0; i < methods.length; i++) {
methodSelect.append('<option value="' + methods[i][0] + '">' + methods[i][1] + '</option>');
}
Expand Down
43 changes: 4 additions & 39 deletions src/js/tools/eoline.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,7 @@ execMain(function(createMove, edgeMove, createPrun, getPruning) {
var moveIdx = ["FRUBLD", "RBULFD", "FLDBRU", "LBDRFU", "FDRBUL", "DBRUFL", "FULBDR", "UBLDFR", "URBDLF", "RDBLUF", "DRFULB", "RUFLDB"];
var rotIdx = ["&nbsp;&nbsp;&nbsp;", "&nbsp;y&nbsp;", "z2&nbsp;", "z2y", "z'&nbsp;", "z'y", "&nbsp;z&nbsp;", "z&nbsp;y", "x'&nbsp;", "x'y", "&nbsp;x&nbsp;", "x&nbsp;y"];

function solve_eoline(scramble, fdiv) {
init();
var moves = cubeutil.parseScramble(scramble, "FRUBLD");
fdiv.empty();
for (var face = 0; face < 12; face++) {
var flip = 0;
var perm = 9 * 12 + 8;
for (var i = 0; i < moves.length; i++) {
var m = moveIdx[face].indexOf("FRUBLD".charAt(moves[i][0]));
var p = moves[i][2];
for (var j = 0; j < p; j++) {
flip = fmv[m][flip];
perm = pmv[m][perm];
}
}
var sol = solv.search([flip, perm], 0);
for (var i = 0; i < sol.length; i++) {
sol[i] = "FRUBLD".charAt(sol[i][0]) + " 2'".charAt(sol[i][1]);
}

fdiv.append($('<span class="sol">').append(faceStr[face] + ": " + rotIdx[face], tools.getSolutionSpan(sol)), '<br>');
}
}

function solve_eocross(scramble, fdiv) {
function solveEOLine(scramble, isCross, fdiv) {
init();
var moves = cubeutil.parseScramble(scramble, "FRUBLD");
fdiv.empty();
Expand All @@ -87,11 +63,8 @@ execMain(function(createMove, edgeMove, createPrun, getPruning) {
perm2 = pmv[m][perm2];
}
}
var sol = solv2.search([flip, perm1, perm2], 0);
for (var i = 0; i < sol.length; i++) {
sol[i] = "FRUBLD".charAt(sol[i][0]) + " 2'".charAt(sol[i][1]);
}

var sol = isCross ? solv2.search([flip, perm1, perm2], 0) : solv.search([flip, perm1], 0);
sol = sol.map((move) => "FRUBLD".charAt(move[0]) + " 2'".charAt(move[1]));
fdiv.append($('<span class="sol">').append(faceStr[face] + ": " + rotIdx[face], tools.getSolutionSpan(sol)), '<br>');
}
}
Expand All @@ -102,11 +75,7 @@ execMain(function(createMove, edgeMove, createPrun, getPruning) {
}
if (tools.isPuzzle('333')) {
var scramble = tools.getCurScramble();
if (type == 'eocross') {
solve_eocross(scramble[1], fdiv);
} else {
solve_eoline(scramble[1], fdiv);
}
solveEOLine(scramble[1], type == 'eocross', fdiv);
} else {
fdiv.html(IMAGE_UNAVAILABLE);
}
Expand All @@ -116,8 +85,4 @@ execMain(function(createMove, edgeMove, createPrun, getPruning) {
tools.regTool('eoline', TOOLS_SOLVERS + '>' + TOOLS_EOLINE, execFunc.bind(null, 'eoline'));
tools.regTool('eocross', TOOLS_SOLVERS + '>' + 'EOCross', execFunc.bind(null, 'eocross'));
});

return {
solve: solve_eoline
}
}, [mathlib.createMove, mathlib.edgeMove, mathlib.createPrun, mathlib.getPruning]);

0 comments on commit 97d89a9

Please sign in to comment.