Exemplo n.º 1
0
    bool SolveMiddleMiddles(ref List <string> path)
    {
        CubeInfo.Cubie        cubie             = null;
        List <CubeInfo.Cubie> middleMiddleCubes = _cubies.AnalyzeMiddleMiddle(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 >= 8); // this hard-codes the order of steps (middle first => 4 cubes, corner next => 8 cubes)
        }

        if (cubie.level == CubeInfo.BOT)
        {
            return(SolveMiddleMiddle_CaseBottom(cubie, ref path));
        }
        else
        {
            Debug.Log("MiddleMiddle cubie right position; wrong ori -> moving to bottom");
            return(SolveMiddleMiddle_CaseMiddle(cubie, ref path)); // move to bottom and then solve
        }
    }