public static bool CrossIsFormed(RubixCube cube, Side side)
        {
            var face = cube.GetFace(side);

            return(CrossFaceIsFormed(cube, side) &&
                   CenterEdgeBlockFacesAreSolved(face, side) &&
                   CentreBlocksAreOnCorrectFaces(cube));
        }
 public static bool SecondLayerIsSolved(RubixCube cube)
 {
     return(FirstLayerIsSolved(cube) &&
            MiddleLayerFacesAreSolved(cube, Side.Left) &&
            MiddleLayerFacesAreSolved(cube, Side.Right) &&
            MiddleLayerFacesAreSolved(cube, Side.Top) &&
            MiddleLayerFacesAreSolved(cube, Side.Bottom));
 }
 private static bool CentreBlocksAreOnCorrectFaces(RubixCube cube)
 {
     return(cube.GetCenterBlockFace(Side.Front) == Colour.White &&
            cube.GetCenterBlockFace(Side.Top) == Colour.Green &&
            cube.GetCenterBlockFace(Side.Back) == Colour.Yellow &&
            cube.GetCenterBlockFace(Side.Bottom) == Colour.Blue &&
            cube.GetCenterBlockFace(Side.Left) == Colour.Red &&
            cube.GetCenterBlockFace(Side.Right) == Colour.Orange);
 }
        public static bool CrossFaceIsFormed(RubixCube cube, Side side)
        {
            var face = cube.GetFace(side);

            return(SideIsCorrectColour(side, face[0, 1]) &&
                   SideIsCorrectColour(side, face[1, 0]) &&
                   SideIsCorrectColour(side, face[1, 2]) &&
                   SideIsCorrectColour(side, face[2, 1]));
        }
 public static bool FirstLayerIsSolved(RubixCube cube)
 {
     return(CubeFaceIsSolved(cube, Side.Front) &&
            CentreBlocksAreOnCorrectFaces(cube) &&
            BottomLayerFacesAreSolved(cube, Side.Left) &&
            BottomLayerFacesAreSolved(cube, Side.Right) &&
            BottomLayerFacesAreSolved(cube, Side.Top) &&
            BottomLayerFacesAreSolved(cube, Side.Bottom));
 }
Ejemplo n.º 6
0
        private static void SolveRubixCube(Options opts)
        {
            var cube      = GetParsedCube(opts);
            var rubixCube = new RubixCube(cube);

            var solver = new RubixCubeSolver(rubixCube);

            solver.Solve();

            using var file = new StreamWriter(opts.OutputPath);
            foreach (var(num, direction, side) in rubixCube.Instructions)
            {
                file.WriteLine($"{num} - {direction}: {side}");
            }
        }
Ejemplo n.º 7
0
        private static void PrintFace(RubixCube cube, Side side)
        {
            var face = cube.GetFace(side);

            for (var row = 0; row < 3; row++)
            {
                Console.Write("                  "); // hack to indent top and bottom faces
                PrintColour(cube.GetColour(face[row, 0], side));
                Console.Write("   ");
                PrintColour(cube.GetColour(face[row, 1], side));
                Console.Write("   ");
                PrintColour(cube.GetColour(face[row, 2], side));
                Console.WriteLine();
                Console.WriteLine();
            }
        }
Ejemplo n.º 8
0
        private static void PrintFaces(RubixCube cube)
        {
            for (var row = 0; row < 3; row++)
            {
                var left = cube.GetFace(Side.Left);
                PrintColour(cube.GetColour(left[row, 0], Side.Left));
                Console.Write("   ");
                PrintColour(cube.GetColour(left[row, 1], Side.Left));
                Console.Write("   ");
                PrintColour(cube.GetColour(left[row, 2], Side.Left));
                Console.Write("   ");

                var front = cube.GetFace(Side.Front);
                PrintColour(cube.GetColour(front[row, 0], Side.Front));
                Console.Write("   ");
                PrintColour(cube.GetColour(front[row, 1], Side.Front));
                Console.Write("   ");
                PrintColour(cube.GetColour(front[row, 2], Side.Front));
                Console.Write("   ");

                var right = cube.GetFace(Side.Right);
                PrintColour(cube.GetColour(right[row, 0], Side.Right));
                Console.Write("   ");
                PrintColour(cube.GetColour(right[row, 1], Side.Right));
                Console.Write("   ");
                PrintColour(cube.GetColour(right[row, 2], Side.Right));
                Console.Write("   ");

                var back = cube.GetFace(Side.Back);
                PrintColour(cube.GetColour(back[row, 0], Side.Back));
                Console.Write("   ");
                PrintColour(cube.GetColour(back[row, 1], Side.Back));
                Console.Write("   ");
                PrintColour(cube.GetColour(back[row, 2], Side.Back));

                Console.WriteLine();
                Console.WriteLine();
            }
        }
Ejemplo n.º 9
0
 public static void Print(RubixCube cube)
 {
     PrintFace(cube, Side.Top);
     PrintFaces(cube);
     PrintFace(cube, Side.Bottom);
 }
 public static bool ThirdLayerIsSolved(RubixCube cube)
 {
     return(((Side[])Enum.GetValues(typeof(Side))).All(side => CubeFaceIsSolved(cube, side)));
 }
        private static bool BottomLayerFacesAreSolved(RubixCube cube, Side side)
        {
            var blocks = cube.GetBottomLayer(side);

            return(BlockFacesAreSolved(side, blocks));
        }
        private static bool CubeFaceIsSolved(RubixCube cube, Side side)
        {
            var face = cube.GetFace(side);

            return(BlockFacesAreSolved(side, face.Cast <Block>()));
        }