Quantum Pong

A game driven by the Schrödinger–Newton equation

-- FPS
The packet begins in a superposition. Move your barrier and measure.
0 · 0
measure: ready / ready
400
Press R to restart match

This has now been several years since I had the idea of this little game, but I never took the time to implement it. But now that AI can give life to any idea with little to no effort, I thought that it might be nice to finally give life to this little experiment.

What is Quantum Pong?

Quantum Pong replaces the classical ball with a two-dimensional wave packet evolving under the non-linear Schrödinger–Newton equation. Before a measurement, the court displays its probability density $|\psi|^2$. The player's racket acts as a movable potential barrier that reflects or diffracts the packet, while a self-gravitational potential pulls the packet together to counteract quantum wave dispersion.

Rules & Controls

The court is rectangular, with scoring zones behind both rackets. Players reposition their potential barriers and trigger measurements. Sampling collapses the wavefunction into a localized state according to the Born rule before serving a fresh wave packet.

PlayerMove BarrierMeasureActivate Kink
Left (Human)W / S or / F or MK
Right (AI)AutomatedAutomatedAutomated
  • Left scores when a measurement lands beyond the right racket; Right scores symmetrically on the left.
  • When measured, the sampled crosshair is highlighted for two seconds. The scoring player receives the next serve directed toward their opponent.
  • A non-scoring measurement launches a new central serve with randomized momentum.
  • Newton Coupling $G$: Adjusting the slider increases or decreases self-gravitational attraction, altering how tightly the wave packet self-traps.
  • R resets the match and score.

Physics: The Schrödinger–Newton Equation & Self-Trapping

In standard linear quantum mechanics, a localized wave packet inevitably undergoes spatial dispersion: its width grows linearly over time as $\sigma(t) = \sigma_0 \sqrt{1 + \frac{\hbar^2 t^2}{m^2 \sigma_0^4}}$, turning a sharp "ball" into a diffuse cloud after only a single wall reflection. To maintain coherent gameplay over multiple rallies, Quantum Pong incorporates the Schrödinger–Newton equation (SNE) (also known as the Newton–Schrödinger or Schrödinger–Poisson system).

The wavefunction $\psi(x,y,t)$ lives on a bounded domain $\Omega = [0, L_x] \times [0, L_y]$ with Dirichlet boundary conditions $\psi|_{\partial\Omega} = 0$. The evolution is governed by the coupled non-linear system:

$$i\hbar \frac{\partial \psi(\mathbf{r},t)}{\partial t} = \left[ -\frac{\hbar^2}{2m}\nabla^2 + V_{\text{ext}}(\mathbf{r},t) + V_{\text{SN}}(\mathbf{r},t) \right] \psi(\mathbf{r},t)$$

where $V_{\text{ext}}(\mathbf{r},t)$ represents the potential barriers created by player paddles and kink modifications. The self-gravitational potential $V_{\text{SN}}(\mathbf{r},t)$ is generated dynamically by the wavefunction's own probability density $\rho(\mathbf{r},t) = |\psi(\mathbf{r},t)|^2$ through the Poisson equation for Newtonian gravity:

$$\nabla^2 V_{\text{SN}}(\mathbf{r},t) = 4\pi G m^2 |\psi(\mathbf{r},t)|^2$$

In integral form with a regularized softening scale $\varepsilon$, the gravitational self-interaction potential takes the form of a 2D Newtonian convolution integral:

$$V_{\text{SN}}(\mathbf{r},t) = -G m^2 \iint_{\Omega} \frac{|\psi(\mathbf{r}',t)|^2}{\sqrt{\|\mathbf{r} - \mathbf{r}'\|^2 + \varepsilon^2}} \, d^2\mathbf{r}'$$

This non-linear term creates an attractive potential well centered at the packet's own center of mass. When the gravitational coupling constant $G$ is sufficiently strong, the self-attraction balances the kinetic pressure of dispersion, giving rise to semi-stable soliton-like self-trapped bound states. This lowers dispersion and keeps the ball localized through repeated paddle reflections.

Numerics: Spectral Convolutions & Split-Step Integration

The simulation runs entirely in WebGL and JavaScript using a dual spectral framework on a grid of up to $1023 \times 511$ points:

  1. Kinetic Step via Discrete Sine Transform (DST-I): Because the court boundaries are zero Dirichlet walls ($\psi\vert{}_{\partial\Omega}=0$), the kinetic operator $T = -\frac{\hbar^2}{2m}\nabla^2$ is exactly diagonalized in a 2D discrete sine mode basis. The exact momentum phase update is applied in $O(N \log N)$ time:
    $$\widehat{\psi}_{pq}(t+\Delta t) = \exp\!\left[-i \frac{\pi^2 \hbar \Delta t}{2m} \left(\frac{p^2}{L_x^2} + \frac{q^2}{L_y^2}\right)\right] \widehat{\psi}_{pq}(t)$$
  2. Gravitational Step via 2D FFT Convolution: At each sub-step, the spatial density $\rho = |\psi|^2$ is convolved with the gravitational Green's function kernel $K(\mathbf{r}) = 1/\sqrt{x^2 + y^2 + \varepsilon^2}$ using 2D Fast Fourier Transforms (FFT).
  3. Operator Splitting: The combined time step integrates kinetic and total potential $V = V_{\text{ext}} + V_{\text{SN}}$ using a second-order symmetric Strang split-step algorithm:
    $$e^{-i(T+V)\Delta t/\hbar} \approx e^{-i V \frac{\Delta t}{2\hbar}} \, e^{-i T \frac{\Delta t}{\hbar}} \, e^{-i V \frac{\Delta t}{2\hbar}}$$

WebGL Engine Realization

This web edition runs the full Schrödinger–Newton solver directly in your browser. Grid transforms (DST-I and 2D FFT convolution) are computed in WebGL GLSL shaders and JavaScript, rendering real-time quantum dynamics at 60 FPS without external desktop dependencies.