Example #1
0
    bool SolveTopMiddle(ref List <string> path)
    {
        CubeInfo.Cubie        cubie          = null;
        List <CubeInfo.Cubie> topMiddleCubes = _cubies.AnalyzeTopMiddle(ref cubie, _solved);

        if (cubie == null)
        {
            return(true);               // no work to do!
        }
        FocusCubie(cubie);
        _cubies.EnableColor(cubie, true);

        // case 1: no work to do -> no work to do, return
        // case 2: cube is in top row, but wrong pos or ori
        // case 3: cube is in middle row
        // case 4: cube is in bottom row

        if (cubie.state == (CubeInfo.POS | CubeInfo.ORI))
        {
            _solved.Add(cubie);
            return(_solved.Count >= 4);
        }

        if (cubie.level == CubeInfo.TOP)
        {
            return(SolveTopMiddle_CaseTop(cubie, ref path));
        }
        else if (cubie.level == CubeInfo.MID)
        {
            return(SolveTopMiddle_CaseMiddle(cubie, ref path));
        }
        else
        {
            return(SolveTopMiddle_CaseBottom(cubie, ref path));
        }
    }