Пример #1
0
        //魔方公式CFOP
        //Cross底面十字(以white为底)
        public void Cross(Cube cube)
        {
            //第一步做成顶部花心形
            while (!(cube.front[1, 1] == cube.front[2, 1] && cube.back[1, 1] == cube.back[0, 1] && cube.left[1, 1] == cube.left[1, 0] && cube.right[1, 1] == cube.right[1, 2] && cube.down[1, 0] == cube.down[1, 1] && cube.down[1, 2] == cube.down[1, 1] && cube.down[0, 1] == cube.down[1, 1] && cube.down[2, 1] == cube.down[1, 1])) 
            {
                //处理底块在第一层侧棱的四种情况
                while ((cube.front[0, 1] == cube.down[1, 1]) || cube.right[1, 0] == cube.down[1, 1] || (cube.back[2, 1] == cube.down[1, 1]) || (cube.left[1, 2] == cube.down[1, 1]))
                {
                    if (cube.front[0, 1] == cube.down[1, 1])
                    {
                        cube.F(cube, 1);
                        cube.exp1(cube);
                    }
                    else if (cube.right[1, 0] == cube.down[1, 1])
                    {
                        cube.R(cube, 1);
                        cube.exp1(cube);
                    }
                    else if (cube.back[2, 1] == cube.down[1, 1])
                    {
                        cube.B(cube, 1);
                        cube.exp1(cube);
                    }
                    else
                    {
                        cube.L(cube, 1);
                        cube.exp1(cube);
                    }
                }
                //处理底块在第二层侧棱的八种情况
                cube.exp1(cube);

                //处理底块在第三层侧棱的四种情况
                while ((cube.front[2, 1] == cube.down[1, 1]) || (cube.right[1, 2] == cube.down[1, 1]) || (cube.back[0, 1] == cube.down[1, 1]) || (cube.left[1, 0] == cube.down[1, 1]))
                {
                    if (cube.front[2, 1] == cube.down[1, 1])
                    {
                        while (cube.up[2, 1] == cube.down[1, 1])
                            cube.U(cube, 1);
                        cube.F(cube, 1);
                        cube.exp1(cube);
                    }
                    else if (cube.right[1, 2] == cube.down[1, 1])
                    {
                        while (cube.up[1, 2] == cube.down[1, 1])
                            cube.U(cube, 1);
                        cube.R(cube, 1);
                        cube.exp1(cube);
                    }
                    else if (cube.back[0, 1] == cube.down[1, 1])
                    {
                        while (cube.up[0, 1] == cube.down[1, 1])
                            cube.U(cube, 1);
                        cube.B(cube, 1);
                        cube.exp1(cube);
                    }
                    else
                    {
                        while (cube.up[1, 0] == cube.down[1, 1])
                            cube.U(cube, 1);
                        cube.L(cube, 1);
                        cube.exp1(cube);
                    }
                }
                //处理底块在第三层底部但位置不对的四种情况
                while ((cube.down[2, 1] == cube.down[1, 1] && cube.front[2, 1] != cube.front[1, 1]) || (cube.down[1, 2] == cube.down[1, 1] && cube.left[1, 0] != cube.left[1, 1]) || (cube.down[0, 1] == cube.down[1, 1] && cube.back[0, 1] != cube.back[1, 1]) || (cube.down[1, 0] == cube.down[1, 1] && cube.right[1, 2] != cube.right[1, 1]))
                {
                    if (cube.down[2, 1] == cube.down[1, 1] && cube.front[2, 1] != cube.front[1, 1])
                    {
                        while (cube.up[2, 1] == cube.down[1, 1])
                            cube.U(cube, 1);
                        cube.F(cube, 1);
                        cube.exp1(cube);
                    }
                    if (cube.down[1, 2] == cube.down[1, 1] && cube.left[1, 0] != cube.left[1, 1])
                    {
                        while (cube.up[1, 0] == cube.down[1, 1])
                            cube.U(cube, 1);
                        cube.L(cube, 1);
                        cube.exp1(cube);
                    }
                    if (cube.down[0, 1] == cube.down[1, 1] && cube.back[0, 1] != cube.back[1, 1])
                    {
                        while (cube.up[0, 1] == cube.down[1, 1])
                            cube.U(cube, 1);
                        cube.B(cube, 1);
                        cube.exp1(cube);
                    }
                    if (cube.down[1, 0] == cube.down[1, 1] && cube.right[1, 2] != cube.right[1, 1])
                    {
                        while (cube.up[1, 2] == cube.down[1, 1])
                            cube.U(cube, 1);
                        cube.R(cube, 1);
                        cube.exp1(cube);
                    }
                }
                //处理中心棱块和十字花的位置
                while (true)
                {
                    if (cube.front[0, 1] == cube.front[1, 1] && cube.up[2, 1] == cube.down[1, 1])
                        cube.F(cube, 2);
                    else if (cube.left[1, 2] == cube.left[1, 1] && cube.up[1, 0] == cube.down[1, 1])
                        cube.L(cube, 2);
                    else if (cube.right[1, 0] == cube.right[1, 1] && cube.up[1, 2] == cube.down[1, 1])
                        cube.R(cube, 2);
                    else if (cube.back[2, 1] == cube.back[1, 1] && cube.up[0, 1] == cube.down[1, 1])
                        cube.B(cube, 2);
                    else if (((cube.front[1, 1] == cube.front[2, 1]) && (cube.back[1, 1] == cube.back[0, 1]) && (cube.left[1, 1] == cube.left[1, 0]) && (cube.right[1, 1] == cube.right[1, 2])) && (cube.down[0, 1] == cube.down[1, 1]) && (cube.down[1, 0] == cube.down[1, 1]) && (cube.down[1, 2] == cube.down[1, 1]) && (cube.down[2, 1] == cube.down[1, 1]))
                        break;
                    else
                        cube.U(cube, 1);
                }
            }
        }