Skip to content

Phase & Interference

Phase is the hidden variable of quantum games. It doesn't change what you'll measure — it changes how quantum properties interact. Phase gates alone are invisible to measurement, but combined with entanglement gates, they redistribute probability through interference.

Clock Gate: Rotating Phase

The clock gate (Z-rotation) adds phase to a property:

typescript
this.clock(prop, fraction);
// fraction=1.0 → full Z gate (π phase on |1⟩)
// fraction=0.5 → half Z (π/2 phase)
// fraction=2.0 → identity (2π = full circle)

After a clock gate, this.getModule().probabilities([prop]) returns the same values. The phase is invisible — until the property interacts with another.

Phase + iSwap = Probability Redistribution

This is the core mechanic: apply phase to one property, then iSwap with another. The relative phase between the two properties determines how probability redistributes.

From Quantum Pong:

typescript
// Player hits paddle → apply phase based on dial position
this.clock(ballProp, phaseFraction);

// Later, ball enters quantum zone → iSwap with partner
this.iSwap(ballProp, partnerProp, 0.5);

// The phase from the paddle hit now biases which ball is more likely to exist

Why this works: iSwap is sensitive to relative phase. Two properties with the same phase interfere constructively (probability adds up). Properties with opposite phase interfere destructively (probability cancels).

Interference Patterns

Constructive Interference

Both properties have similar phase → probability concentrates:

typescript
this.clock(propA, 0.5);   // +π/2 phase
this.clock(propB, 0.5);   // +π/2 phase (same)
this.iSwap(propA, propB, 0.5);
// Probability concentrates on propA (or propB, depending on initial state)

Destructive Interference

Properties have opposite phase → probability cancels:

typescript
this.clock(propA, 0.5);    // +π/2 phase
this.clock(propB, -0.5);   // -π/2 phase (opposite)
this.iSwap(propA, propB, 0.5);
// Probability spreads more evenly — the phases cancel

Grover Oracle Pattern

Used by: Hex Diffusion

The Grover oracle marks specific states with a π phase flip, then a diffusion operator (Hadamard) converts that phase difference into a probability difference. This creates "walls" and "barriers" that reflect probability.

typescript
// Mark "wall" hexes with π phase
const wallPredicates: PredicateSpec[] = [
  { property: hexProp, value: wallState, isEqual: true }
];
this.phaseRotate(wallPredicates, Math.PI);

// Diffusion step spreads probability
this.hadamard(hexProp, 0.1); // fractional H for gradual diffusion

The effect: probability approaching a wall reflects back via destructive interference. Hexes marked with π phase become barriers that quantum probability "bounces off."

This is a genuine quantum algorithm (Grover's search) repurposed as a game mechanic.

Visualizing Phase

Phase is invisible to measurement but visible in the reduced density matrix. Games extract and display it in different ways:

Quantum Pong — Orbit Speed

The phase dial shows relative phase as a rotating indicator:

typescript
const phase = registry.getRelativePhase(ballA, ballB);
// phase: -π to π radians
// Map to dial rotation angle
dialAngle = phase;

Bloch Invaders — Color Hue

The Bloch sphere representation maps phase to hue:

typescript
const rdm = this.getModule().reduced_density_matrix([prop]);
const phi = Math.atan2(rdm[offDiag].value.imag, rdm[offDiag].value.real);
// Map phi to HSL hue for the invader's glow color
invaderHue = (phi / (2 * Math.PI) + 0.5) * 360;

Ponq — Coherence-Driven Forces

Off-diagonal magnitude in the density matrix represents coherence — how much the property is "in superposition" vs. collapsed. Ponq uses this as a physics force:

typescript
const rdm = this.getModule().reduced_density_matrix([prop]);
const offDiag = rdm.find(e => e.row_values[0] !== e.col_values[0]);
const coherence = Math.sqrt(offDiag.value.real ** 2 + offDiag.value.imag ** 2);
// coherence: 0 (fully collapsed) to 0.5 (maximally superposed)
// Use as steering force magnitude
steeringForce = coherence * MAX_FORCE;

Quantris — Compass Display

Phase mapped to a compass direction shown on quantum pieces:

typescript
const phase = registry.getPhaseAngle(pieceId);
compassDirection = phase; // renders as an arrow on the piece

Phase Rotation Reference

AngleEffectName
0No changeIdentity
π/4Subtle biasT gate equivalent
π/2Quarter turnS gate equivalent
πFull flipZ gate equivalent
Full circleBack to identity

Key Insight

Phase is the "control knob" that lets players influence quantum outcomes without directly choosing them. The player can't pick which ball exists — but they can bias the odds by applying phase before the next entanglement interaction. This creates a skill gap: experienced players learn to use phase strategically, while the quantum randomness keeps outcomes surprising.

Powered by Quantum Forge