cubing.js
cubing.js copied to clipboard
OrientationTracker contains dead and/or incorrect code
Steps to reproduce the issue
In src/cubing/stream/process/ReorientedStream.ts you can find the following code snippet:
} else if (move.family.slice(-1) === "w") {
const [rotation, family] = rotationMap[move.family.slice(-1)];
return this.processMove(rotation).concat(
this.processMove(move.modified({ family })),
);
}
Observed behaviour
Note that rotationMap is defined as:
const rotationMap: Record<string, [Move, string]> = {
U: [new Move("y"), "D"],
L: [new Move("x'"), "R"],
F: [new Move("z"), "B"],
R: [new Move("x"), "L"],
B: [new Move("z"), "F"],
D: [new Move("y'"), "U"],
};
So when the above snippet tries to look up "w", which it must do if the if passes, it will get undefined. So either moves ending in "w" are never provided as input to this code, or some likely unintended effect will happen.
Expected behaviour
Probably the intention here is not to look up w but to look up slice(-2,-1) instead.
Environment
All platforms.
🖼 Screenshots
No response
Additional info
No response
Sounds quite possible!
Steps to reproduce the issue
I assume you were trying to use the code; do you have a short snippet that hits this?
No, I don't have a snippet for it -- I wanted to rewrite my solutions in terms of the orientation the user was looking at the cube and I couldn't find a way to do it. I can file another issue for what I wanted to do but I found it easier to implement against onionhoney's moves so I implemented it there instead.
I filed #229 to record what I was looking for when I read this code.