Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Quantum Chinese Chess] Improve chess board printing #176

Merged
merged 5 commits into from
May 8, 2024

Conversation

madcpf
Copy link
Collaborator

@madcpf madcpf commented Jan 31, 2024

  • Print the board with sampled probabilities.
  • For proper print, different treatment is made for English vs Chinese and Sublime terminus vs mac/gLinux terminal.

Pengfei Chen added 2 commits January 30, 2024 14:53
@madcpf madcpf marked this pull request as draft January 31, 2024 04:29
@madcpf madcpf marked this pull request as ready for review January 31, 2024 19:23
@madcpf madcpf requested a review from dstrain115 January 31, 2024 19:23
@madcpf
Copy link
Collaborator Author

madcpf commented Jan 31, 2024

Not sure why some other files fail Lint check.

Copy link
Collaborator

@dstrain115 dstrain115 left a comment

Choose a reason for hiding this comment

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

Cool improvement, but let's make sure its portable!

@@ -28,6 +28,20 @@
# The default initial state of the game.
_INITIAL_FEN = "RHEAKAEHR/9/1C5C1/P1P1P1P1P/9/9/p1p1p1p1p/1c5c1/9/rheakaehr w---1"

# Constants for printing board
_RESET = "\033[0m"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does all this work in colab? I'm not sure how portable all these unix terminal codes are. If it works in colab though, that's probably good enough

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi Doug, yes I just checked that it works in cola, with https://colab.research.google.com/drive/1B-7LmTN_gL4T1akVqUtoYO5dwzK_3IVK?usp=sharing, but replaced the files with this PR.

print_probabilities=True,
peek_result: List[int] = None,
sublime_terminus: bool = True,
):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add docstring for the arguments. It particular, I am not sure what sublime_terminus is? Is it a specific terminal app?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks Doug. It's added. Sublime Text is a handy editor, while Sublime Terminus is its integrated terminal.

probabilities: List[float] = None,
print_probabilities=True,
peek_result: List[int] = None,
sublime_terminus: bool = True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd consider making this an enum rather than a bool, and add a plain option, such as:

class TerminalType(enum.Enum):
    PLAIN_ASCII = 0
    MAC_AND_LINUX = 1
    SUBLIME_TERMINUS = 2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks Doug. I just added MAC_OR_LINUX and SUBLIME_TERMINUS_OR_COLAB (since it turns out that colab handles full width chars in a similar way as sublime terminus). What do you mean about plain ascii?

Pengfei Chen added 2 commits February 5, 2024 11:35
@madcpf madcpf requested a review from dstrain115 February 5, 2024 19:49
@madcpf madcpf merged commit af4f671 into quantumlib:main May 8, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants