예제 #1
0
        public void isRedundantCCW()
        {
            RotationSequence myList = new RotationSequence();

            myList.addRotation(new Rotation(Face.FRONT, Direction.CCW));
            myList.addRotation(new Rotation(Face.FRONT, Direction.CCW));
            Assert.AreEqual(true, myList.isRedundant(new Rotation(Face.FRONT, Direction.CCW)));
        }
예제 #2
0
        public static void BuildFilesForRotation(RubikFileWriter p_firstFloorFile, RubikFileWriter p_secondFloorFile, RubikFileWriter p_thirdFloorFile
                                                 , Cube p_rubik
                                                 , Cube p_initialPermutation, RotationSequence p_rotationLinkedList, int p_level, String p_progressString)
        {
            if (p_level == 0)
            {
                return;
            }
            if (p_level > 5)
            {
                Console.WriteLine(p_progressString);
            }
            int i = 0;

            foreach (Face face in Enum.GetValues(typeof(Face)))
            {
                foreach (Direction direction in Enum.GetValues(typeof(Direction)))
                {
                    i++;
                    String   myProgressString = p_progressString + String.Format(".%d", i);
                    Rotation newRotation      = new Rotation(face, direction);
                    if (p_rotationLinkedList.isRedundant(newRotation))
                    {
                        continue;
                    }
                    p_rotationLinkedList.addRotation(newRotation);
                    p_rubik.rotateFace(newRotation.getFace(), newRotation.getDirection());
                    if (CubeStatus.isDifferentItemsInFirstFloorLessThanThree(p_rubik, p_initialPermutation))
                    {
                        p_rotationLinkedList.writeToFile(p_firstFloorFile);
                    }
                    if (CubeStatus.isDifferentItemsOnlyInSecondFloorLessThanThree(p_rubik, p_initialPermutation))
                    {
                        p_rotationLinkedList.writeToFile((p_secondFloorFile));
                    }
                    if (CubeStatus.changesOnlyInThirdFloor(p_rubik, p_initialPermutation))
                    {
                        p_rotationLinkedList.writeToFile(p_thirdFloorFile);
                    }

                    BuildFilesForRotation(p_firstFloorFile, p_secondFloorFile, p_thirdFloorFile,
                                          p_rubik, p_initialPermutation, p_rotationLinkedList, p_level - 1, myProgressString);
                    p_rotationLinkedList.removeRotation();
                    p_rubik.rotateFace(newRotation.getReverse().getFace(), newRotation.getReverse().getDirection());
                }
            }
        }