Example #1
0
        public static IRubiksCube Clockwise(IRubiksCube cube, IFace face)
        {
        return new RubiksCube(
            getF: coordinate =>
            {
                if (coordinate.Face.Equals(face))
                {
                    return cube[new Coordinate(coordinate.Face, Rotate(coordinate.Position))];
                }

                var direction = face.Diff(coordinate.Face);

                if (direction != null)
                {
                    // WTF???

                    var rotated = Rotate(direction);
                    var before = face.Neighbour(rotated);

                    for (int index = -1; index < 2; index++)
                    {
                        if (coordinate.Position.Equals(face.Matching(direction, index)))
                        {
                            var relative = coordinate.Face.Diff(before);

                            coordinate = coordinate.Travel(ref relative, count: 3);

                            return cube[coordinate];
                        }
                    }
                }

                return cube[coordinate];
            });
        }
Example #2
0
 public static IPosition Matching(this IFace view, IDirection direction, int index)
 {
     return view.Matching(direction).Edge(view.Mapping(direction) * index);
 }