public bool Equals(UnitRotation other)
        {
            if (other == null)
            {
                return(false);
            }

            return(Id.Equals(other.Id));
        }
Example #2
0
        public Cube Rotate(UnitRotation rotation)
        {
            var side    = GetSide(rotation.Direction);
            var pieces  = side.Pieces;
            var others  = Positions.Except(pieces);
            var rotated = pieces.Select(x => x.Rotate(rotation));

            return(new Cube(rotated.Concat(others), Rotations.Concat(new [] { rotation })));
        }
Example #3
0
        public Cube Scramble(int iterations = 200)
        {
            var          cube     = this;
            UnitRotation previous = null;

            while (iterations > 0)
            {
                var rotation = Rotation.AllRotations.Values.Where(x => !x.Reverse.Equals(previous)).ToList().SelectRandom();
                cube     = cube.Rotate(rotation);
                previous = rotation;
                iterations--;
            }

            return(cube);
        }