Example #1
0
        private void findBetterSolution(Solution p_solution, RotationTree p_tree, SolutionManager p_solutionManager,
                                        int p_floor)
        {
            Rubik       l_rubik        = new Rubik();
            Permutation l_permutation  = p_solution.getPermutation().getCopy();
            int         l_minimumValue = l_permutation.getValue(p_floor);

            //	if (l_minimumValue < 8)
            //		l_minimumValue = 8;
            l_rubik.setPermutation(l_permutation);
            searchTree(l_minimumValue - 4, p_tree, l_rubik, p_solutionManager,
                       p_solution, p_floor, 0);
        }
Example #2
0
        public void searchTree(int p_minimumValue, RotationTree p_tree,
                               Rubik p_rubik, SolutionManager p_solutionManager,
                               Solution p_prevSolution, int p_floor, int depth)
        {
            if (p_minimumValue < 2)
            {
                p_minimumValue = 2;
            }
            Permutation l_permutation = p_rubik.getPermutation().getCopy();
            Rubik       l_rubik       = new Rubik();

            for (int i = 0; i < p_tree.getSize(); i++)
            {
                RotationLinkedList l_rotationLinkedList = p_tree.getRotationLinkedList(i);
                if (l_rotationLinkedList != null)
                {
                    l_rubik.setPermutation(l_permutation);
                    for (int j = 0; j < l_rotationLinkedList.size(); j++)
                    {
                        l_rubik.rotateFace(l_rotationLinkedList.get(j));
                    }
                    Permutation l_resultPermutation = l_rubik.getPermutation().getCopy();

                    if (l_resultPermutation.getValue(p_floor) >= p_minimumValue)
                    {
                        p_solutionManager.addSolution(l_rotationLinkedList, l_resultPermutation, p_prevSolution, l_resultPermutation.getValue(p_floor), p_floor);
                    }
                    if (p_floor == 3 && depth == 0)
                    {
                        //  Console.WriteLine("Hi");
                        searchTree(p_minimumValue, p_tree, l_rubik, p_solutionManager,
                                   new Solution(l_rotationLinkedList, l_resultPermutation, p_prevSolution), p_floor, 1);
                    }
                }
            }
        }