Esempio n. 1
0
        public static int GetOrientation(Rubik rubik, Cube c)
        {
            int orientation = 0;

            if (c.IsEdge)
            {
                CubeFlag targetFlags = rubik.GetTargetFlags(c);
                Rubik    clone       = rubik.DeepClone();

                if (!targetFlags.HasFlag(CubeFlag.MiddleLayer))
                {
                    while (RefreshCube(clone, c).Position.HasFlag(CubeFlag.MiddleLayer))
                    {
                        clone.RotateLayer(c.Position.X, true);
                    }

                    Cube clonedCube = RefreshCube(clone, c);
                    Face yFace      = clonedCube.Faces.First(f => f.Color == rubik.TopColor || f.Color == rubik.BottomColor);
                    if (!FacePosition.YPos.HasFlag(yFace.Position))
                    {
                        orientation = 1;
                    }
                }
                else
                {
                    Face zFace = c.Faces.First(f => f.Color == rubik.FrontColor || f.Color == rubik.BackColor);
                    if (c.Position.HasFlag(CubeFlag.MiddleLayer))
                    {
                        if (!FacePosition.ZPos.HasFlag(zFace.Position))
                        {
                            orientation = 1;
                        }
                    }
                    else
                    {
                        if (!FacePosition.YPos.HasFlag(zFace.Position))
                        {
                            orientation = 1;
                        }
                    }
                }
            }
            else if (c.IsCorner)
            {
                Face face = c.Faces.First(f => f.Color == rubik.TopColor || f.Color == rubik.BottomColor);
                if (!FacePosition.YPos.HasFlag(face.Position))
                {
                    if (FacePosition.XPos.HasFlag(face.Position) ^ !((c.Position.HasFlag(CubeFlag.BottomLayer) ^ (c.Position.HasFlag(CubeFlag.FrontSlice) ^ c.Position.HasFlag(CubeFlag.RightSlice)))))
                    {
                        orientation = 1;
                    }
                    else
                    {
                        orientation = 2;
                    }
                }
            }

            return(orientation);
        }
Esempio n. 2
0
        // *** METHODS ***

        /// <summary>
        /// Returns the solution for the transferred Rubik
        /// </summary>
        /// <param name="cube">Defines the Rubik to be solved</param>
        protected virtual void Solve(Rubik cube)
        {
            Rubik     = cube.DeepClone();
            Algorithm = new Algorithm();
            InitStandardCube();

            GetSolution();
            RemoveUnnecessaryMoves();
        }
Esempio n. 3
0
        /// <summary>
        /// Returns the solution for the transferred Rubik
        /// </summary>
        /// <param name="cube">Defines the Rubik to be solved</param>
        public virtual void Solve(Rubik cube)
        {
            Rubik     = cube.DeepClone();
            Algorithm = new Algorithm(null);
            InitStandardCube();

            GetSolution();
            Algorithm = Algorithm.RemoveUnnecessaryMoves(Algorithm);
        }
        protected override void Solve(Rubik cube)
        {
            Rubik         = cube.DeepClone();
            _coordCube    = ToCoordCube(cube);
            this.MaxDepth = 30;
            this.TimeOut  = 10000;
            Algorithm     = new Algorithm();
            InitStandardCube();

            GetSolution();
            RemoveUnnecessaryMoves();
        }
        public override void Solve(Rubik cube)
        {
            this.Rubik    = cube.DeepClone();
            _coordCube    = TwoPhaseHelpers.ToCoordCube(cube);
            this.MaxDepth = 30;
            this.TimeOut  = 10000;
            Algorithm     = new Algorithm(null);
            InitStandardCube();

            GetSolution();
            Algorithm = Algorithm.RemoveUnnecessaryMoves(Algorithm);
        }
Esempio n. 6
0
 public TestScenario(Rubik rubik, Algorithm moves)
 {
     Rubik     = rubik.DeepClone();
     Algorithm = moves;
 }
 public BeginnerSolver(Rubik cube)
 {
     Rubik          = cube.DeepClone();
     this.Algorithm = new Algorithm();
     InitStandardCube();
 }