Example #1
0
    void Start()
    {
        _cube.init(transform);
        _cubies.init(transform);
        _solver.init(_cubies, _cube);

        if (startState == "Random")
        {
            string[]      choices = { "F", "F", "F2",
                                      "B",      "B", "B2",
                                      "R",      "R", "R2",
                                      "L",      "L", "L2",
                                      "U",      "U", "U2",
                                      "D",      "D", "D2" };
            int           maxMoves = 10;
            System.Random random   = new System.Random();
            for (int i = 0; i < maxMoves; i++)
            {
                int    idx = random.Next(0, choices.Length);
                string cmd = choices[idx];
                _cube.turn(cmd);
                Debug.Log(cmd);
            }
        }
        else
        {
            char[]   delimiterChars = { ' ' };
            string[] words          = startState.Split(delimiterChars);
            for (int w = 0; w < words.Length; w++)
            {
                string word = words[w];
                _cube.turn(word);
            }
        }

        for (int i = 0; i < _cubies.GetNumCubes(); i++)
        {
            CubeInfo.Cubie cubie = _cubies.GetCubeInfo(i);
            if (_cubies.IsCenterCube(i))
            {
                _cubies.EnableColor(cubie, true);
            }
            else
            {
                _cubies.EnableColor(cubie, false);
            }
        }

        _tasks.Add(new CubeTask(SolveTopMiddle, _cubies.TopMiddleSolved, "top row", "middle cubes"));
        _tasks.Add(new CubeTask(SolveTopCorners, _cubies.TopCornersSolved, "top row", "corner cubes"));
        _tasks.Add(new CubeTask(SolveMiddleMiddles, _cubies.MiddleMiddleSolved, "middle row", "middle cubes"));
        _tasks.Add(new CubeTask(SolveOneCornerPosition, _cubies.BottomOneCornerCorrect, "bottom row", "choose anchor corner"));
        _tasks.Add(new CubeTask(SolveBottomCornerPositions, _cubies.BottomCornersCorrectPositions, "bottom row", "corner cube positions"));
        _tasks.Add(new CubeTask(SolveBottomMiddlePositions, _cubies.BottomMiddlesCorrectPositions, "bottom row", "middle cube positions"));
        _tasks.Add(new CubeTask(SolveBottomCornerOri, _cubies.BottomCornersCorrectOri, "bottom row", "twirl corners"));
        _tasks.Add(new CubeTask(SolveBottomMiddleOri, _cubies.BottomMiddlesCorrectOri, "bottom row", "flip middles"));
    }