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] Update flying general check #168

Merged
merged 8 commits into from
Nov 29, 2023

Conversation

madcpf
Copy link
Collaborator

@madcpf madcpf commented Oct 30, 2023

  • Update flying general check to include the cases where there are quantum pieces between two kings(aka generals).
  • Update Move to not depend on Board to break the cyclic dependency.

@madcpf madcpf changed the title Update flying general check [Quantum Chinese Chess] Update flying general check Oct 30, 2023
@madcpf madcpf requested a review from dstrain115 October 30, 2023 19:39
# Let the general/king fly, i.e. the opposite king will capture the current king.
current_king = self.board[self.king_locations[self.current_player]]
oppsite_king = self.board[self.king_locations[1 - self.current_player]]
Jump(MoveVariant.CLASSICAL)(oppsite_king, current_king)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The game ends here, right? So, is it necessary to actually move the king? I guess there's no reason not to, but it seems unnecessary.

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 the game ends here. I just chose to capture the other king so that later on we print the updated board as the last print of the game.

print("==== FLYING GENERAL ! ====")
return True
else:
# TODO(): we are leaving the path pieces unchanged in entangled state. Maybe
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is fine, right? since we measured the ancilla, it's guaranteed that all states remaining on the board have some piece in between.

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. Yes I've updated the comment here.

result = board.flying_general_check()
# We check the ancilla to learn whether the general/king flies or not.
captured = world.post_selection[world["ancilla_ancilla_flying_general_check_0_0"]]
if captured:
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to know that each branch of the if statement happens. (That some of the time it is captured and some of the time it is not).

One way to get one branch deterministically would be to test this:

    board = set_board(["a3", "e0", "e9"])
    board.king_locations = ["e0", "e9"]
    board.current_player = 0  # i.e. RED
    alpha.PhasedSplit()(world["a3"], world["e3"], world["e5"])

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 this case as a separate test, where capture could not happen. But I cannot think of a way to deterministically make sure the capture happens.

@madcpf madcpf requested a review from dstrain115 November 10, 2023 03:39
@madcpf madcpf merged commit eef96ad into quantumlib:main Nov 29, 2023
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