Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected rotation for algs that start and end in different orientations #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion js/RubiksCube.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ function obfusticate(algorithm, numPremoves=3, minLength=16){
//Cube.initSolver();
var premoves = getPremoves(numPremoves);
var rc = new RubiksCube();

rc.doAlgorithm(alg.cube.invert(premoves) + algorithm);
orient = alg.cube.invert(rc.wcaOrient());
var solution = alg.cube.simplify(premoves + (alg.cube.invert(rc.solution())) + orient).replace(/2'/g, "2");
Expand Down Expand Up @@ -722,6 +723,15 @@ class AlgTest {
}
}

// Adds extra rotations to the end of an alg to reorient
function correctRotation(alg) {
var rc = new RubiksCube();
rc.doAlgorithm(alg);
var ori = rc.wcaOrient();

return alg + " " + ori;
}

function generateAlgTest(){

var set = document.getElementById("algsetpicker").value;
Expand All @@ -747,7 +757,7 @@ function generateAlgTest(){
solutions = rawAlgs;
}

var scramble = generateAlgScramble(solutions[0],set,obfusticateAlg,shouldPrescramble);
var scramble = generateAlgScramble(correctRotation(solutions[0]),set,obfusticateAlg,shouldPrescramble);
if (set == "F3L"){
solutions = [alg.cube.invert(scramble).replace(/2'/g, "2")];
}
Expand Down