DEV Community

Cover image for Exploring Quantum Entanglement: The CHSH Game Simulator
Malcolm Low
Malcolm Low

Posted on • Originally published at malcolmlow.com

Exploring Quantum Entanglement: The CHSH Game Simulator

Have you ever wondered how quantum mechanics defies everyday intuition? This project demonstrates one of the most striking phenomena in quantum physics: quantum entanglement and its ability to violate classical physics constraints through a playable cooperative game.

🎮 Try the CHSH Game Simulator |
📂 View on GitHub


1 · What is the CHSH Game?

The CHSH (Clauser-Horne-Shimony-Holt) game is a cooperative thought experiment that reveals the strange power of quantum entanglement. Two players, Alice and Bob, cannot communicate during the game but may share a pre-agreed strategy or, crucially, a pair of entangled qubits.

Player Receives from referee Outputs
Alice Random bit x Bit a
Bob Random bit y Bit b

They win if and only if:

(a + b) mod 2 = x × y
Enter fullscreen mode Exit fullscreen mode

With classical strategies, Alice and Bob can win at most 75% of the time. With a quantum strategy using entangled qubits, they can reach approximately 85.4%, violating the classical bound.

2 · Bell’s Inequality and the CHSH Value

In 1964, John Bell proved that no local hidden variable theory can reproduce all predictions of quantum mechanics. The CHSH inequality formalises Bell’s theorem as a single testable number S:

Theory CHSH Value (S) Win Rate
Classical (any local strategy) S ≤ 2 75%
Quantum mechanics S = 2√2 ≈ 2.828 ~85.4%

This violation is not a loophole or a trick. It proves that the correlations produced by entangled qubits cannot be explained by any shared classical information, even with pre-agreed randomness. Loophole-free Bell test experiments confirm that quantum entanglement is a genuine physical phenomenon with no classical analogue.

3 · Measurement Angles and Quantum Correlation

The quantum advantage arises from choosing measurement bases at specific angles. For the standard |Φ+⟩ Bell state, the optimal angles are:

Player Input bit Measurement basis
Alice x = 0 0°
Alice x = 1 45°
Bob y = 0 22.5°
Bob y = 1 −22.5°

The probability that Alice and Bob produce the same outcome is:

P(same) = cos²(δ)
Enter fullscreen mode Exit fullscreen mode

where δ is the angle between their chosen measurement bases. This quantum correlation is what enables them to exceed the 75% classical ceiling. Different Bell states exhibit either parallel correlation (|Φ+⟩, |Ψ+⟩: qubits tend to give the same outcome) or orthogonal correlation (|Φ−⟩, |Ψ−⟩: one qubit effectively rotated 90° relative to the other). The simulator adjusts its probability calculations accordingly for each state.

🧪 4 · The Four Bell States

The simulator supports all four maximally entangled Bell states. Each uses optimised measurement angles to achieve the theoretical quantum win rate of ~85%.

State Definition Correlation
|Φ+⟩ (|00⟩ + |11⟩) / √2 Parallel
|Φ−⟩ (|00⟩ − |11⟩) / √2 Orthogonal
|Ψ+⟩ (|01⟩ + |10⟩) / √2 Parallel
|Ψ−⟩ (|01⟩ − |10⟩) / √2 Orthogonal

🎯 5 · Simulator Features

Feature Details
🎯 Interactive Visualization Real-time p5.js visualization showing the entangled state, Alice’s measurement collapse, and Bob’s final measurement. Coloured basis quadrants and correlation indicators included.
🎮 Strategy Comparison Switch between Classical (always outputs 0, max 75%) and Quantum (entangled qubits, ~85.4%) strategies in real time.
🎲 Flexible Input Controls Set Alice’s x and Bob’s y to Random or Fixed (0 or 1) to test specific measurement configurations.
📊 Real-Time Statistics Running totals for rounds played, wins, losses, and win percentage converging toward theoretical predictions.
🔄 Round History Navigation Step through previous rounds to review specific outcomes and trace the quantum measurement process.

Built with: React, p5.js, and Claude Code

6 · Try It Yourself!

A suggested sequence to build intuition:

  1. Open the simulator and select the Classical strategy. Run 100 rounds and watch the win rate converge toward 75%.
  2. Switch to the Quantum strategy with the |Φ+⟩ Bell state. Run another 100 rounds and observe the rate climb toward 85%.
  3. Try the other three Bell states. Note how each state’s correlation type (parallel vs orthogonal) affects the outcome distribution.
  4. Set Alice and Bob’s inputs to Fixed values to test individual measurement configurations and trace the correlation manually.
  5. Use Round History to step back through specific rounds and verify the win condition (a + b) mod 2 = x × y by hand.

7 · Open Source

The complete source code is on GitHub. Contributions welcome: explore the code, report issues, suggest improvements, or fork it to build your own quantum visualisations.

Planned enhancements include a 3D Bloch sphere visualisation (Three.js), step-by-step animated transitions, an in-app educational tutorial, a mathematical deep-dive panel, and improved mobile layout.

The CHSH game demonstrates that quantum entanglement is not a mathematical abstraction but a measurable, observable phenomenon with no classical analogue. This simulator makes that phenomenon interactive and accessible to anyone curious about quantum mechanics.



Part of the Quantum Series 2026. Originally published on Techucation.

Top comments (0)