Beispiel #1
0
        public override Task<IEnumerable<IRotation>> Solve(CubeConfiguration<FaceColour> configuration)
        {
            base.Solve(configuration).Wait();
            var solution = new List<IRotation>();

            for (int i = 0; i < 40; i++)
            {
                if (m_random.Next(1, 5) == 1)
                {
                    m_lastCubeRotation = GenerateRandomCubeRotation();
                    solution.Add(m_lastCubeRotation);
                }
                else
                {
                    m_lastFaceRotation = GenerateRandomRotation();
                    solution.Add(m_lastFaceRotation);
                }
            }

            return Task.FromResult<IEnumerable<IRotation>>(solution);
        }
Beispiel #2
0
 public Task RotateCube(CubeRotation rotation)
 {
     return m_cubeAnimator.RotateCube(rotation);
 }
Beispiel #3
0
 public Task RotateCube(CubeRotation rotation)
 {
     return m_window.DisplayControl.RotateCube(rotation);
 }
        private static IEnumerable<CubeRotation> CondenseDoubleRotations(CubeRotation current, CubeRotation previous)
        {
            if (current.Axis == previous.Axis)
            {
                var currentMultiplier = current.Direction == RotationDirection.Clockwise ? 1 : -1;
                var previousMultiplier = previous.Direction == RotationDirection.Clockwise ? 1 : -1;

                var totalTimes = currentMultiplier * current.Count + previousMultiplier * previous.Count;

                if (totalTimes % 4 == 0) return new List<CubeRotation>();
                if (totalTimes % 2 == 0) return new List<CubeRotation> { CubeRotations.ByAxisTwice(current.Axis) };
                if (totalTimes % 3 == 0) return new List<CubeRotation> { CubeRotations.ByAxis(current.Axis, RotationDirection.AntiClockwise) };
                if (totalTimes == 1) return new List<CubeRotation> { CubeRotations.ByAxis(current.Axis, RotationDirection.Clockwise) };
            }

            return new List<CubeRotation> { previous, current };
        }
 public Task RotateCube(CubeRotation rotation)
 {
     return Scene.RotateCube(rotation);
 }
 public Task RotateCube(CubeRotation rotation)
 {
     return StartRotating(rotation);
 }