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

change enum.Piece to add color and language #158

Merged
merged 9 commits into from
Oct 2, 2023
Merged

Conversation

madcpf
Copy link
Collaborator

@madcpf madcpf commented Sep 29, 2023

  • Add Language and Color as new enum classes;
  • Rename enum class Piece to be Type;
  • In a new file define class Piece inheriting from QuantumObject.

@madcpf madcpf marked this pull request as draft October 2, 2023 18:17
@madcpf madcpf marked this pull request as ready for review October 2, 2023 20:12
@madcpf madcpf requested a review from losos0 October 2, 2023 20:13
GENERAL = ["g", "G", "将", "帥"]

@staticmethod
def type_of(c: str) -> Optional["Type"]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function is no longer correct, it won't handle the Chinese symbols, correct?

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. This method (currently) is only used for convert FEN symbols into board pieces. I will rewrite it if further needs merge.


def black_symbol(self) -> str:
return self.value
EMPTY = [".", ".", ".", "."]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would probably use tuples instead of lists here, since you do not want them to be mutable.

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 updated.

self.type_ = type_
self.color = color

def symbol(self, lang: Language = Language.EN) -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it worth adding color as an argument then moving this as part of Type?

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 updated.

@madcpf madcpf requested a review from dstrain115 October 2, 2023 21:51
return type_.value[2]
elif color == Color.BLACK:
return type_.value[3]
return "Unexpected combinations"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would probably raise an ValueError rather than silently pass a weird string.

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 updated.

@madcpf madcpf merged commit 2c414f6 into quantumlib:main Oct 2, 2023
6 checks passed
@madcpf madcpf deleted the add_enum branch October 2, 2023 22:18
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