Example #1
0
        static void Main(string[] args)
        {
            var cube = new CubeBuilder(1).BuildCube();
             var printer = new CubePrinter(cube);
             var query = new CubeQuery(cube);
             var rotator = new CubeRotator(query);
             using (var sw = File.CreateText("cube.txt"))
             {
            printer.PrintAsCutout(sw);
            cube.Print("cube1.txt");
            //rotator.RotateOuterLayer(Directions.Front, Directions.Clockwise);
            //cube.Print("cube2.txt");
            //printer.PrintAsCutout(sw);
            //rotator.RotateOuterLayer(Directions.Front, Directions.CounterClockwise);
            //printer.PrintAsCutout(sw);
            //rotator.RotateOuterLayer(Directions.Right, Directions.CounterClockwise);
            //printer.PrintAsCutout(sw);

            //_cubeRandomizer.Randomize(rotator, 20);
            Hardest(rotator);
            cube.Print("cube3.txt");
            cube.PrintAsCutout("cubeasCutout0.txt");
            Time(1, () => Solve(rotator, cube, query));
            cube.Print("cube5.txt");
            printer.PrintAsCutout(sw);
             }
        }
Example #2
0
        private static void Hardest(CubeRotator rotator)
        {
            rotator.RotateCube(Directions.Up, -90);

             rotator.RotateLayer(Directions.Front, 90);
             rotator.RotateLayer(Directions.Up, -90);
             rotator.RotateLayer(Directions.Front, 180);
             rotator.RotateLayer(Directions.Down, -90);
             rotator.RotateLayer(Directions.Back, 90);
             rotator.RotateLayer(Directions.Up, 90);
             rotator.RotateLayer(Directions.Right, -90);
             rotator.RotateLayer(Directions.Front, -90);
             rotator.RotateLayer(Directions.Left, 90);
             rotator.RotateLayer(Directions.Down, -90);
             rotator.RotateLayer(Directions.Right, -90);
             rotator.RotateLayer(Directions.Up, -90);
             rotator.RotateLayer(Directions.Left, 90);
             rotator.RotateLayer(Directions.Up, 90);
             rotator.RotateLayer(Directions.Back, -90);
             rotator.RotateLayer(Directions.Down, 180);
             rotator.RotateLayer(Directions.Right, -90);
             rotator.RotateLayer(Directions.Front, 90);
             rotator.RotateLayer(Directions.Up, 180);
             rotator.RotateLayer(Directions.Down, 180);
        }
Example #3
0
 protected Solver(Cube cube, ICubeLayerRotator cubeLayerRotator)
 {
     Cube = cube;
      Query = new CubeQuery(cube);
      Rotator = new CubeRotator(cube);
      SetFrontDirection(Directions.Front, Directions.Up);
      _cubeLayerRotator = cubeLayerRotator;
 }
 private void RandomlyRotateCubeLayer(CubeRotator cubeRotator)
 {
     var dir = GetRandomDirection();
      var rot = GetRandomAngle();
      cubeRotator.RotateLayer(dir, rot);
 }
 public void Randomize(CubeRotator cubeRotator, int count = 1000)
 {
     for (int i = 0; i < count; i++)
     RandomlyRotateCubeLayer(cubeRotator);
 }
Example #6
0
 private static void Solve(CubeRotator rotator, Cube cube, CubeQuery query)
 {
     using (var movesText = File.CreateText("Moves.txt"))
      {
     MoveCounter bestMoveCounter = null;
     var moveCounter = new MoveCounter();
     var rotators = new CubeLayerRotatorList(
        new MoveWriter(movesText),
        moveCounter,
        rotator);
     var solver = new FirstLayerEdgeSolver(cube, query.GetCenterFacelet(Colors.White), rotators);
     var faceletsToSolveCount = solver.GetCountOfFaceletsToSolve();
     if (faceletsToSolveCount == 0)
        return;
     var permutations = Permutations.Instance.GetPermutations(faceletsToSolveCount);
     foreach (var permutation in permutations)
     {
        var cubeState = cube.GetState();
        SolveHelper(cube, solver, permutation);
        facelets to solve is out of sync.
        if (bestMoveCounter == null || bestMoveCounter.MoveCount > moveCounter.MoveCount)
           bestMoveCounter = moveCounter;
        cubeState.Restore();
        movesText.WriteLine(moveCounter.ToString());
        moveCounter = new MoveCounter();
        rotators = new CubeLayerRotatorList(
           new MoveWriter(movesText),
           moveCounter,
           rotator);
        solver = new FirstLayerEdgeSolver(cube, query.GetCenterFacelet(Colors.White), rotators);
     }
     movesText.WriteLine(bestMoveCounter.ToString());
      }
 }