Ejemplo n.º 1
0
        public MoveCollection TransformMoves(CubeOrientation orientation)
        {
            MoveCollection newMoves = new MoveCollection();

            for (IEnumerator <Move> e = GetEnumerator(); e.MoveNext();)
            {
                Move m = e.Current;
                newMoves.Add(orientation.TransformFace(m.Face), m.Count);
            }

            return(newMoves);
        }
Ejemplo n.º 2
0
        protected override void CalcMoves()
        {
            int             count = 0;
            CubeOrientation orientation;
            MoveCollection  moves;

            if (!OllSolved())
            {
                for (count = 0; count < 4; count++)
                {
                    if (OllPatterns.Any(e => e.pattern.IsMatch(cube)))
                    {
                        break;
                    }

                    DoMove(CubeFace.DOWN, addMove: false);
                }
                moves = OllPatterns.First(e => e.pattern.IsMatch(cube)).algorithm;
                DoMove(CubeFace.DOWN, 4 - count, false);

                orientation = new CubeOrientation(MiddleLayerFaces[count], CubeFace.UP);

                this.moves.AddRange(moves.TransformMoves(orientation));
            }

            for (count = 0; count < 4; count++)
            {
                if (PllPatterns.Any(p => p.pattern.IsMatch(cube)))
                {
                    break;
                }

                DoMove(CubeFace.DOWN, addMove: false);
            }
            moves = OllPatterns.First(p => p.pattern.IsMatch(cube)).algorithm;
            DoMove(CubeFace.DOWN, 4 - count, false);

            orientation = new CubeOrientation(MiddleLayerFaces[count], CubeFace.UP);

            this.moves.AddRange(moves.TransformMoves(orientation));

            if (!GetCubeSolved())
            {
                throw new InvalidProgramException();
            }
        }