예제 #1
0
    bool SolveBottomMiddleOri(ref List <string> path)
    {
        CubeInfo.Cubie        cubie  = null;
        List <CubeInfo.Cubie> bottom = _cubies.AnalyzeBottomMiddleOri(ref cubie, _solved);

        if (cubie == null)
        {
            return(true);               // no work to do
        }
        for (int i = 0; i < _cubies.GetNumCubes(); i++)
        {
            CubeInfo.Cubie c = _cubies.GetCubeInfo(i);
            if (!_cubies.IsCenterCube(i) && !_cubies.BottomRow(c))
            {
                _cubies.EnableColor(c, false);
            }
            else
            {
                _cubies.EnableColor(c, true);
            }
        }

        foreach (CubeInfo.Cubie c in bottom)
        {
            if (!_cubies.IsSolved(c))
            {
                FocusCubie(c);
                break;
            }
        }

        string[] down  = { "D", "D'", "D2", "" };
        string[] seqnA =
        {
            "F U' D R2 U2 D2 L",
            "L U' D F2 U2 D2 B",
            "B U' D L2 U2 D2 R",
            "R U' D B2 U2 D2 F"
        };
        string[] seqnB =
        {
            "L' D2 U2 R2 D' U F'",
            "B' D2 U2 F2 D' U L'",
            "R' D2 U2 L2 D' U B'",
            "F' D2 U2 B2 D' U R'"
        };

        ArrayList steps = new ArrayList();

        for (int i = 0; i < seqnA.Length; i++)
        {
            steps.Clear();
            string[] words = seqnA[i].Split();
            foreach (string word in words)
            {
                string[] tmp = { word };
                steps.Add(tmp);
            }
            steps.Add(down);
            words = seqnB[i].Split();
            foreach (string word in words)
            {
                string[] tmp = { word };
                steps.Add(tmp);
            }
            steps.Add(down);
            path = _solver.Search(cubie, _solved, steps, _solver.ScoreSolved);
            if (path.Count > 0)
            {
                break;
            }
        }

        return(path.Count > 0);
    }