def run_magic_square_game(
    sampler: cirq.Sampler,
    alice_qubits: list[cirq.GridQubit],
    bob_qubits: list[cirq.GridQubit],
    repetitions: int = 10_000,
    add_dd: bool = True,
    dd_scheme: tuple[cirq.Gate, ...] = (cirq.X, cirq.Y, cirq.X, cirq.Y),
) -> MagicSquareResult:
    """Run the magic square game.

    Args:
        sampler: The hardware sampler or simulator.
        alice_qubits: Alice's qubits, order is (measure, measure, data, data, measure) or (measure,
            data, data, measure).
        bob_qubits: Bob's qubits, (order is measure, measure, data, data, measure) or (measure,
            data, data, measure).
        repetitions: The number of repetitions for each row and column of the Mermin-Peres square.
        add_dd: Whether to add dynamical decoupling.
        dd_scheme: The dynamical decoupling sequence to use if doing DD.

    Returns:
        A MagicSquareResult object containing the experiment results.
    """

    all_circuits = []
    for mermin_row in range(3):
        for mermin_col in range(3):
            all_circuits.append(
                construct_magic_square_circuit(
                    alice_qubits, bob_qubits, mermin_row, mermin_col, add_dd, dd_scheme
                )
            )

    results = sampler.run_batch(all_circuits, repetitions=repetitions)

    alice_measurements = np.zeros((3, 3, repetitions, len(alice_qubits) - 2), dtype=bool)
    bob_measurements = np.zeros((3, 3, repetitions, len(bob_qubits) - 2), dtype=bool)
    idx = 0
    for row in range(3):
        for col in range(3):
            alice_measurements[row, col] = results[idx][0].measurements["alice"]
            bob_measurements[row, col] = results[idx][0].measurements["bob"]
            idx += 1

    return MagicSquareResult(alice_measurements, bob_measurements)
Run the magic square game.

    Args:
        sampler: The hardware sampler or simulator.
        alice_qubits: Alice's qubits, order is (measure, measure, data, data, measure) or (measure,
            data, data, measure).
        bob_qubits: Bob's qubits, (order is measure, measure, data, data, measure) or (measure,
            data, data, measure).
        repetitions: The number of repetitions for each row and column of the Mermin-Peres square.
        add_dd: Whether to add dynamical decoupling.
        dd_scheme: The dynamical decoupling sequence to use if doing DD.

    Returns:
        A MagicSquareResult object containing the experiment results.
    
examples/magic_square.py