Пример #1
0
        public void GetName_RotationHasACountGreaterThan1_NameEndsWithTheCount(int count)
        {
            var rotation = new FaceRotation { Count = count };

            var name = rotation.GetName();

            StringAssert.EndsWith(count.ToString(), name);
        }
Пример #2
0
        public void GetName_RotationIsAntiClockwise_NameEndsWithApostrophe()
        {
            var rotation = new FaceRotation { Direction = RotationDirection.AntiClockwise };

            var name = rotation.GetName();

            StringAssert.EndsWith("'", name);
        }
Пример #3
0
        public void GetName_RotationHasACounOf1_NameDoesNotEndWithTheCount()
        {
            var rotation = new FaceRotation { Count = 1 };

            var name = rotation.GetName();

            StringAssert.DoesNotEndWith("1", name);
        }
Пример #4
0
        public void GetName_RotationIsOnFace_NameStartsWithCorrectLetter(FaceType face, string firstLetter)
        {
            var rotation = new FaceRotation { Face = face };

            var name = rotation.GetName();

            StringAssert.StartsWith(firstLetter, name);
        }
Пример #5
0
        public void GetName_RotationIsClockwise_NameDoesNotEndWithApostrophe()
        {
            var rotation = new FaceRotation { Direction = RotationDirection.Clockwise };

            var name = rotation.GetName();

            StringAssert.DoesNotEndWith("'", name);
        }
Пример #6
0
        public void GetName_RotationIsForLayer0_NameDoesNotContainAUnicodeCharacter()
        {
            var rotation = new FaceRotation { LayerNumberFromFace = 0 };

            var name = rotation.GetName();

            StringAssert.DoesNotContain("\x2080", name);
            StringAssert.DoesNotContain("\x2081", name);
            StringAssert.DoesNotContain("\x2082", name);
            StringAssert.DoesNotContain("\x2083", name);
            StringAssert.DoesNotContain("\x2084", name); 
            StringAssert.DoesNotContain("\x2085", name);
            StringAssert.DoesNotContain("\x2086", name);
            StringAssert.DoesNotContain("\x2087", name);
            StringAssert.DoesNotContain("\x2088", name);
            StringAssert.DoesNotContain("\x2089", name);
        }
Пример #7
0
        private static IEnumerable<FaceRotation> CondenseDoubleRotations(FaceRotation current, FaceRotation previous)
        {
            if (current.Face == previous.Face && current.LayerNumberFromFace == previous.LayerNumberFromFace)
            {
                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<FaceRotation>();
                if (totalTimes % 2 == 0) return new List<FaceRotation> { Rotations.ByFaceTwice(current.Face, current.LayerNumberFromFace) };
                if (totalTimes % 3 == 0) return new List<FaceRotation> { Rotations.ByFace(current.Face, RotationDirection.AntiClockwise, current.LayerNumberFromFace) };
                if (totalTimes == 1) return new List<FaceRotation> { Rotations.ByFace(current.Face, RotationDirection.Clockwise, current.LayerNumberFromFace) };
            }

            return new List<FaceRotation> { previous, current };
        }
Пример #8
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);
        }
Пример #9
0
 public Task Rotate(FaceRotation faceRotation)
 {
     return m_cubeAnimator.Rotate(faceRotation);
 }
Пример #10
0
 public Task Rotate(FaceRotation faceRotation)
 {
     return m_window.DisplayControl.Rotate(faceRotation);
 }
Пример #11
0
        public void GetName_RotationIsForLayerNonZeroLayerLessThan9_NameContainsUnicodeCharacterForOneMoreThanTheLayer(int layer, string unicodeChar)
        {
            var rotation = new FaceRotation { LayerNumberFromFace = layer };

            var name = rotation.GetName();

            StringAssert.Contains(unicodeChar, name);
        }
Пример #12
0
        public void GetName_RotationIsForLayerLayerNumberGreaterThan8_NameContainsMultipleUnicodeCharacters(int layer, string unicodeChar)
        {
            var rotation = new FaceRotation { LayerNumberFromFace = layer };

            var name = rotation.GetName();

            StringAssert.Contains(unicodeChar, name);
        }
 public Task Rotate(FaceRotation rotation)
 {
     return Scene.Rotate(rotation);
 }
Пример #14
0
 public Task Rotate(FaceRotation rotation)
 {
     return StartRotating(rotation);
 }