public void writeToFile(RubikFileWriter p_writer)
        {
            foreach (var l_itr in c_array)
            {
                (l_itr as Rotation).writeToFile(p_writer);
            }

            p_writer.write("\n");
        }
        public static void findGoodRotationLinks(String p_firstFloorFile
                                                 , String p_secondFloorFile, String p_thirdFloorFile, int p_levels)
        {
            RubikFileWriter    l_firstWriter        = new RubikFileWriter(p_firstFloorFile);
            RubikFileWriter    l_secondWriter       = new RubikFileWriter(p_secondFloorFile);
            RubikFileWriter    l_thirdWriter        = new RubikFileWriter(p_thirdFloorFile);
            Rubik              l_rubik              = new Rubik();
            Permutation        l_initialPermutation = l_rubik.getPermutation();
            RotationLinkedList l_rotationLinkedList = new RotationLinkedList();

            BuildFilesForRotation(l_firstWriter, l_secondWriter, l_thirdWriter
                                  , l_rubik, l_initialPermutation, l_rotationLinkedList, p_levels, "");
            l_firstWriter.close();
            l_secondWriter.close();
            l_thirdWriter.close();
        }
        public static void BuildFilesForRotation(RubikFileWriter p_firstFloorFile, RubikFileWriter p_secondFloorFile, RubikFileWriter p_thirdFloorFile
                                                 , Rubik p_rubik
                                                 , Permutation p_initialPermutation, RotationLinkedList 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(".{0}", i);
                    Rotation newRotation      = new Rotation(face, direction);
                    if (p_rotationLinkedList.isRedundant(newRotation))
                    {
                        continue;
                    }
                    p_rotationLinkedList.addRotation(newRotation);
                    p_rubik.rotateFace(newRotation);
                    if (p_rubik.isDifferentItemsInFirstFloorLessThanThree(p_initialPermutation))
                    {
                        p_rotationLinkedList.writeToFile(p_firstFloorFile);
                    }
                    if (p_rubik.isDifferentItemsOnlyInSecondFloorLessThanThree(p_initialPermutation))
                    {
                        p_rotationLinkedList.writeToFile((p_secondFloorFile));
                    }
                    if (p_rubik.changesOnlyInThirdFloor(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());
                }
            }
        }
Exemple #4
0
        public void writeToFile(RubikFileWriter p_write)
        {
            String l_toWrite = String.Format(" ({0},{1})", c_face.getInt(), c_direction.getInt());

            p_write.write(l_toWrite);
        }