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

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

        foreach (CubeInfo.Cubie c in bottom)
        {
            if (_cubies.IsSolved(c))
            {
                _cubies.EnableColor(c, true);
                FocusCubie(c);
            }
        }

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

        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);
    }