public static PuzzleStateAndGenerator ApplyOrientation(CubePuzzle puzzle, CubeMove[] randomOrientation, PuzzleStateAndGenerator psag, bool discardRedundantMoves) { if (randomOrientation.Length == 0) { return(psag); } // Append reorientation to scramble. try { var ab = new AlgorithmBuilder(MergingMode.NoMerging, puzzle.GetSolvedState()); ab.AppendAlgorithm(psag.Generator); foreach (var cm in randomOrientation) { ab.AppendMove(cm.ToString()); } psag = ab.GetStateAndGenerator(); return(psag); } catch (InvalidMoveException e) { Assert(false, e.Message, e); return(null); } }
public CubeMove(Face face, int dir, int innerSlice, int outerSlice, CubePuzzle p) { _puzzle = p; Face = face; Direction = dir; InnerSlice = innerSlice; OuterSlice = outerSlice; // We haven't come up with names for moves where outerSlice != 0 Assert(outerSlice == 0); }
public CubeState(CubePuzzle cp) : base(cp) { _puzzle = cp; _image = ArrayExtension.New <int>(6, _puzzle.Size, _puzzle.Size); for (var face = 0; face < _image.Length; face++) { for (var j = 0; j < _puzzle.Size; j++) { for (var k = 0; k < _puzzle.Size; k++) { _image[face][j][k] = face; } } } _normalizedState = this; }
public static PuzzleStateAndGenerator ApplyOrientation(CubePuzzle puzzle, CubeMove[] randomOrientation, PuzzleStateAndGenerator psag, bool discardRedundantMoves) { if (randomOrientation.Length == 0) { return(psag); } // Append reorientation to scramble. try { var ab = new AlgorithmBuilder(MergingMode.NoMerging, puzzle.GetSolvedState()); ab.AppendAlgorithm(psag.Generator); // Check if our reorientation is going to cancel with the last // turn of our scramble. If it does, then we just discard // that last turn of our scramble. This ensures we have a scramble // with no redundant turns, and I can't see how it could hurt the // quality of our scrambles to do this. var firstReorientMove = randomOrientation[0].ToString(); while (ab.IsRedundant(firstReorientMove)) { //azzert(discardRedundantMoves); var im = ab.FindBestIndexForMove(firstReorientMove, MergingMode.CanonicalizeMoves); ab.PopMove(im.Index); } foreach (var cm in randomOrientation) { ab.AppendMove(cm.ToString()); } psag = ab.GetStateAndGenerator(); return(psag); } catch (InvalidMoveException e) { Assert(false, e.Message, e); return(null); } }
public CubeState(int[][][] image, CubePuzzle cp) : base(cp) { _puzzle = cp; _image = image; }
public CubeMove(Face face, int dir, int innerSlice, CubePuzzle p) : this(face, dir, innerSlice, 0, p) { }
public CubeMove(Face face, int dir, CubePuzzle p) : this(face, dir, 0, p) { }