-
Notifications
You must be signed in to change notification settings - Fork 362
[Feature,Refactor] Chess improvements: fen, pgn, pixels, san #2702
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/2702
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
torchrl/envs/custom/chess.py
Outdated
# Generate the PGN string | ||
pgn_string = str(game) | ||
return pgn_string | ||
|
||
@classmethod | ||
def _get_fen(cls, tensordict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this function can be removed, in favor of a direct TensorDict.get
call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that one day we might let people choose the fen / pgn key for themselves but it's true that as of now it's not incredibly useful
torchrl/envs/custom/chess.py
Outdated
fen = self._get_fen(tensordict).data | ||
dest = tensordict.empty() | ||
if self.include_pgn: | ||
fen = self._get_pgn(tensordict).data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fen = self._get_pgn(tensordict).data | |
pgn = self._get_pgn(tensordict).data |
Also _get_pgn
doesn't exist, but I figure you realize that
@classmethod | ||
def _get_tensor_image(cls, board): | ||
try: | ||
svg = board._repr_svg_() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could have another option that has a more minimal representation as well, if we want to train without vision. For instance, OpenSpiel's chess env has a representation where each square of the board is given a size 20 array of ones and zeros, which is somehow used to represent which piece is in that square and which color it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I was using this because it's builtin - but a more minimal representation could also be cool!
Stack from ghstack (oldest at bottom):