Beispiel #1
0
    public int ScoreSolved(CubeInfo.Cubie cubie, List <CubeInfo.Cubie> constraints)
    {
        bool requirements = _cubies.IsSolved(cubie);

        for (int i = 0; i < constraints.Count && requirements; i++)
        {
            CubeInfo.Cubie info = constraints[i] as CubeInfo.Cubie;
            if (!_cubies.IsSolved(info))
            {
                requirements = false;
            }
        }

        if (!requirements)
        {
            return(0);
        }

        int score = 0;

        for (int i = 0; i < _cubies.GetNumCubes(); i++)
        {
            CubeInfo.Cubie info = _cubies.GetCubeInfo(i);
            if (_cubies.CorrectPos(info))
            {
                score++;
            }
            if (_cubies.CorrectOri(info))
            {
                score++;
            }
        }
        return(score);
    }
Beispiel #2
0
    void Update()
    {
        if (!demo)
        {
            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                //List<string> path = new List<string>();
                //SolveOneCornerPosition(ref path);
                //ExecutePath(path); // changes planning cube immediately
                //Debug.Log("TEST " + PathToString(path)+" "+ _cubies.BottomOneCornerCorrect());

                //List<string> path = new List<string>();
                //SolveBottomMiddlePositions(ref path);
                //ExecutePath(path); // changes planning cube immediately
                //Debug.Log("TEST " + PathToString(path)+" "+ _cubies.BottomMiddlesCorrectPositions());

                //List<string> path = new List<string>();
                //SolveBottomCornerOri(ref path);
                //ExecutePath(path); // changes planning cube immediately
                //Debug.Log("TEST " + PathToString(path)+" "+ _cubies.BottomCornersCorrectOri());

                //List<string> path = new List<string>();
                //SolveBottomMiddleOri(ref path);
                //ExecutePath(path); // changes planning cube immediately
                //Debug.Log("TEST " + PathToString(path)+" "+ _cubies.BottomMiddlesCorrectOri());
            }
            else if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                //Test("B' D B R D' R' D2"); // Run Test1: D R D2 R'  B' D' B

                // Test analyzing the bottom face of cubes
                //List<CubeInfo.Cubie> bottomCornerCubes = _cubies.AnalyzeBottomCorners( ref sorted);
                //List<string> path = new List<string>();
                //SolveBottomCornerPositions(ref path);
                //ExecutePath(path); // changes planning cube immediately
                //Debug.Log("TEST " + PathToString(path)+" "+ _cubies.BottomCornersCorrectPositions());

                //UpdateCubeState(); // only want to do this once in the beginning
                // in the future, we don't need a shadow cube
            }

            if (Input.GetKeyDown(KeyCode.Space) && NotAnimating())
            {
                _cube.SortCubeGroups();

                StepTask();
            }
        }
        else
        {
            if (NotAnimating() && !_cubies.IsSolved())
            {
                _cube.SortCubeGroups();

                List <string> path = new List <string>();
                SolveTask(ref path);

                Debug.Log("PATH " + PathToString(path));
                AnimatePath(path); // for visuals, changes display cube over many frames
            }
        }
    }