Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion magiccube/cube_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ def _print_top_down_face(self, cube, face):
result += "\n"
return result

def print_cube(self):
def print_cube(self, orientation: str = ''):
Copy link
Owner

@trincaog trincaog Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, could we make this support CubeMove/CubeMoveType object as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I have corrected the PR accordingly tell me if it's OK for you.

"Print the cube to stdout"
cube = self.cube

if orientation:
cube.rotate([orientation])

# flatten midle layer
print_order_mid = zip(cube.get_face(Face.L), cube.get_face(Face.F),
cube.get_face(Face.R), cube.get_face(Face.B))
Expand All @@ -76,4 +79,11 @@ def print_cube(self):

# BOTTOM
result += self._print_top_down_face(cube, Face.D)

if orientation:
cube.rotate([orientation])
if cube._store_history:
cube._history.pop()
cube._history.pop()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a new undo method, which seems helpful here.

Suggested change
cube.rotate([orientation])
if cube._store_history:
cube._history.pop()
cube._history.pop()
cube.undo()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, it's implemented !


return result