This simulator generates random lozenge tilings of arbitrary polygonal regions on the triangular lattice, supporting both uniform and q-volume weighted distributions.
How to use:
- Draw mode: Click or drag on the triangular grid to add triangles to your region
- Erase mode: Remove triangles from your region
- Hexagon preset: Quickly generate a standard hexagonal region with sides (a,b,c,a,b,c)
- Scale Up Region: Double the size of your current region while preserving its shape
- Make Tileable: If your region is invalid, this adds the minimum number of triangles from the exterior boundary to make it tileable. For each unmatched triangle, it finds an adjacent exterior neighbor of the opposite color.
A region is tileable (valid) if and only if it has equal numbers of black and white triangles AND they can be perfectly matched. The simulator uses Dinic's maximum flow algorithm to find a perfect matching when one exists.
Uniform and q-Volume Sampling:
The simulator samples from two main distributions:
- Uniform (q=1): Each valid tiling has equal probability
- q-Volume weighted (q≠1): Each tiling has probability proportional to qvolume, where volume is the 3D volume under the corresponding stepped surface. When q>1, higher-volume (flatter) tilings are favored; when q<1, lower-volume (more tilted) tilings are favored.
- Periodic weights: Position-dependent q values arranged in a k×k matrix (k=1,2,3,4,5). At position (n,j) on the triangular lattice, the flip probability uses qn mod k, j mod k. This creates spatially varying weight patterns that can produce interesting limit shapes and phase transitions. Two presets are provided:
- Charlier-Duits-Kuijlaars 2×2: Matrix [[α, 1], [1, 1/α]] with tunable parameter α. See Charlier (2020) and Duits-Kuijlaars (2021).
- Nienhuis-Hilhorst-Blöte 3×3: Matrix [[1, α, 1/α], [1/α, 1, α], [α, 1/α, 1]] with tunable parameter α. Based on Nienhuis, Hilhorst, Blöte (1984).
- Imaginary q-Racah weights: Height-dependent weighting where flip acceptance uses qj + q2J−j based on the local height j and a tunable parameter J. This creates non-uniform distributions that depend on the height function value at each position.
Sampling methods:
- Glauber dynamics (Start/Stop): Markov chain Monte Carlo that performs local "flips" of three lozenges around hexagonal vertices. Converges to the uniform (q=1) or q-volume weighted distribution over time.
- Perfect Sample (CFTP): Coupling From The Past algorithm that produces an exact sample from the uniform (or q-weighted) distribution in finite time, with no burn-in period required. It works by running coupled Markov chains backward in time until they coalesce. Early coalescence detection checks every 1000 steps for faster termination.
Hole Constraints: For regions with holes, you can control the height change around each hole. Click the + or − buttons that appear inside each hole to adjust this constraint. Both Glauber dynamics and CFTP respect these constraints when sampling. Note that a lozenge tiling with hole might not correspond to a correct 3D shape, and fun discontinuities will arise.
Drawing & Editing Tools:
- Lasso Selection: Click multiple points to define a polygon. Click near the start to close the loop, or use Cmd/Ctrl-Click to close immediately. Supports Snap to Grid for precise lattice alignment.
- Scale Region: Instantly Double (scale up) or Halve (scale down) the current region size.
- Undo/Redo: Full history support for shape modifications.
Presets:
- Text: Generate regions shaped like letters (A-Z) or numbers (0-9).
- Shape of the Month: Loads a curated complex polygon.
Visualization Modes:
- 2D Lozenge: Standard flat tiling view.
- 2D Dimer: Displays the underlying matching on the dual graph.
- 3D Height Function: Renders the tiling as a stepped surface in 3D space. Supports rotation, panning, and zooming.
- Color Palettes: Multiple color schemes available, with permutation support to cycle colors.
Sampling & Analysis:
- Average Sample: Runs parallel CFTP chains to compute the mean height function (Limit Shape).
- Fluctuations (GFF): Visualizes the height difference between two perfect samples (scaled by √2), approximating the Gaussian Free Field.
- Double Dimer: Superimposes two independent samples to form loops. Includes a Min Loop Size filter to analyze loop statistics.
Data Export:
- Images: Export high-quality PNG or PDF.
- Geometry: Import/Export the region shape as JSON.
- Scientific Data: Export the computed Height Function as a CSV file or Mathematica array for external analysis.
Performance: The simulation runs entirely in your browser. When available, it uses WebGPU compute shaders for massively parallel Glauber dynamics and CFTP sampling, based on the chromatic sweep approach from Keating-Sridhar (2018). On systems without WebGPU, it falls back to multi-threaded WebAssembly (up to 4 cores) for parallel CFTP chains, or single-threaded WASM with optimized pre-computed caches and Lemire's fast bounded random.