示例#1
0
    bool SolveBottomCornerPositions(ref List <string> path)
    {
        List <CubeInfo.Cubie> bottomCorners = _cubies.FindBottomCorners();
        bool sorted = _cubies.BottomCornersSorted();

        FocusCubie(new Vector3(-1, -2, -1));


        for (int i = 0; i < _cubies.GetNumCubes(); i++)
        {
            if (!_cubies.IsCenterCube(i))
            {
                _cubies.EnableColor(_cubies.GetCubeInfo(i), false);
            }
        }

        foreach (CubeInfo.Cubie c in bottomCorners)
        {
            _cubies.EnableColor(c, true);
        }

        // case 1: sorted but possible needs a rotation
        // case 2: need to rotate three
        // case 3: need to swap consecutive cubies
        // case 4: need to swap opposite cubies
        if (sorted)
        {
            string[]  down  = { "D", "D'", "D2", "" };
            ArrayList steps = new ArrayList();
            steps.Add(down);
            path = _solver.Search(null, _solved, steps, _solver.ScorePositions);
        }
        else
        {
            ArrayList steps     = new ArrayList();
            string[]  down      = { "D", "D'", "D2", "" };
            string[]  sequences =
            {
                // rotate C
                "L' D R D' L D R' D'",
                "F' D B D' F D B' D'",
                "R' D L D' R D L' D'",
                "B' D F D' B D F' D'",

                // rotate CC
                "D R D' L' D R' D' L",
                "D B D' F' D B' D' F",
                "D L D' R' D L' D' R",
                "D F D' B' D F' D' B",

                // swap consecutive
                "F D' B' D F' D' B D2",
                "B D' F' D B' D' F D2",
                "L D' R' D L' D' R D2",
                "R D' L' D R' D' L D2",

                // swap non-consecutive
                "D F D L D' L' F'",
                "D R D F D' F' R'",
                "D B D R D' R' B'",
                "D L D B D' B' L'"
            };

            // ASN TODO: We know the sequence if we analyze the cube more closely
            foreach (string seqn in sequences)
            {
                steps.Clear();
                //steps.Add(down);
                string[] words = seqn.Split();
                foreach (string word in words)
                {
                    string[] tmp = { word };
                    steps.Add(tmp);
                }
                path = _solver.Search(null, _solved, steps, _solver.ScorePositions);
                if (path.Count > 0)
                {
                    break;
                }
            }
        }

        return(path.Count > 0);
    }