Esempio n. 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);
             }
        }
Esempio n. 2
0
 protected Solver(Cube cube, ICubeLayerRotator cubeLayerRotator)
 {
     Cube = cube;
      Query = new CubeQuery(cube);
      Rotator = new CubeRotator(cube);
      SetFrontDirection(Directions.Front, Directions.Up);
      _cubeLayerRotator = cubeLayerRotator;
 }
Esempio n. 3
0
 public CubeRotator(CubeQuery cubeQuery)
 {
     _cube = cubeQuery.Cube;
      _cubeQuery = cubeQuery;
 }
Esempio n. 4
0
 public CubePrinter(Cube cube)
 {
     _cube = cube;
      _cubeQuery = new CubeQuery(cube);
      _page = new char[_height * _length];
 }
Esempio n. 5
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());
      }
 }