Skip to content

Contextuality: MagicSquare game#448

Open
alejogoogle wants to merge 3 commits intoquantumlib:mainfrom
alejogoogle:mermin-peres-game
Open

Contextuality: MagicSquare game#448
alejogoogle wants to merge 3 commits intoquantumlib:mainfrom
alejogoogle:mermin-peres-game

Conversation

@alejogoogle
Copy link
Contributor

No description provided.

@dstrain115 dstrain115 self-requested a review December 17, 2025 00:37
alice_choices[2, :, :, :2] = 1 - self.alice_measurements[2, :, :, :2]
bob_choices[:, 0, :, 0] = self.bob_measurements[:, 0, :, 1]
bob_choices[:, 0, :, 1] = self.bob_measurements[:, 0, :, 0]
bob_choices[:, 1:, :, :2] = self.bob_measurements[:, 1:, :, :2]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a lot of unexplained matrix manipulation. Can we add a line or two to the docstring to explain how Alice and Bob's choices are generated.

first two.

Returns:
Alice and Bob's choices in the game.
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are returned as two numpy arrays. Can we explain in what format Alice and Bob's choices are returned?

alice_choices[2, :, :, :2] = 1 - self.alice_measurements[2, :, :, :2]
bob_choices[:, 0, :, 0] = self.bob_measurements[:, 0, :, 1]
bob_choices[:, 0, :, 1] = self.bob_measurements[:, 0, :, 0]
bob_choices[:, 1:, :, :2] = self.bob_measurements[:, 1:, :, :2]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks very similar to the above code. Is there a way we can combine them?
Same with below.

if np.sum(alice_triad) % 2 == 0 and np.sum(bob_triad) % 2 == 1:
number_of_matches += 1
if alice_triad[col] == bob_triad[row]:
win_matrix[row, col] += 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like repeated code from get_multiply_matrix below. Can we call that instead?

@@ -0,0 +1,749 @@
# Copyright 2025 Google
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add tests for this file.

@mhucka
Copy link
Collaborator

mhucka commented Jan 15, 2026

In addition to addressing Doug's comments about the code, I think also it's important to add a description to the pull request. Here are some points to address:

  • What is this PR for? What does it actually do? From the title, one can infer it concerns a game, but that's about it – the title doesn't say if this PR adds code for a game, or fixes a problem with exiting code, or something else. (We shouldn't assume that the reader of the PR will take time to read the code in order to deduce these things.)

  • What is the relevance to the contextuality work? Is this game mentioned in the paper, or is it just a fun supplement, or something else? (We shouln't assume that the reader will go look at the paper to figure that out.)

  • Is this related to any other PR or issue in the ReCirq repo?

  • Does this game require new libraries that aren't already in the project's requirements?

I realize it's more work to write a description, and I'm sorry for that. Perhaps an AI tool can help with this in some way.

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.

3 participants