コード例 #1
0
        public void searchTree(int minimumValueToReach, RotationTree searchTree,
                               Cube cubeToSolve, SolutionManager solutionManager,
                               Solution previousSolution, int targetFloorToSortInCube, int depth)
        {
            if (minimumValueToReach < 2)
            {
                minimumValueToReach = 2;
            }
            for (int rotationSequenceIndex = 0; rotationSequenceIndex < searchTree.getSize(); rotationSequenceIndex++)
            {
                RotationSequence rotationSequence = searchTree.getRotationSequence(rotationSequenceIndex);
                if (rotationSequence != null)
                {
                    Cube cubeAfterRotationSequence = getCubeAfterApplyingSequence(new Cube(cubeToSolve), rotationSequence);

                    addSequenceToSolutionIfHigherValue(minimumValueToReach, solutionManager, previousSolution,
                                                       targetFloorToSortInCube, rotationSequence, cubeAfterRotationSequence);
                    if (targetFloorToSortInCube == 3 && depth == 0)
                    {
                        this.searchTree(minimumValueToReach, searchTree, cubeAfterRotationSequence, solutionManager,
                                        new Solution(rotationSequence, cubeAfterRotationSequence, previousSolution), targetFloorToSortInCube, 1);
                    }
                }
            }
        }