A frog hops across the Gaussian primes, looking for a way to infinity.
Gaussian integers a + bi are the lattice points of the plane, and the primes among them (a^2 + b^2 prime, or a prime of the form 4k + 3 on an axis) form a tapestry with the eightfold symmetry of the square; Eisenstein primes do the same on the triangular lattice with twelvefold symmetry. A frog starts at the origin and may only land on primes, jumping at most k. Whether some finite k lets it walk to infinity is the open Gaussian moat problem: computers have found moats for every jump up to the square root of 26 and beyond, but there is no proof. A breadth-first flood fill over a map of radius 1,100 finds every prime the frog can reach, a few hop layers per frame, and the union of disks of radius k / 2 around them is drawn as the frog's island, since two disks touch exactly when the frog can jump between them. When the flood stops, a second pass finds the narrowest gap across the moat, the frog hops there along a shortest path, and the jump widens to exactly that gap so it can leap across.
Try it. Drag the jump slider (or use the arrow keys and plus or minus) to change the maximum jump, and toggle Gaussian and Eisenstein primes with the button or E. Click any prime to drop the frog there and flood from it, and press Space to leap the moat once the frog is stuck. Drag to pan, scroll or pinch to zoom, and hover a prime to see its norm and how many hops it took.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build an interactive picture of the Gaussian moat problem with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window. Use a deep teal background.
- Sieve the ordinary primes up to about 40,000 into a Uint8Array.
- A Gaussian integer a + bi is prime when a and b are both nonzero and a^2 + b^2 is prime, or when one is zero and the other's absolute value is a prime of the form 4k + 3. Draw every Gaussian prime with |a| and |b| up to 150 as a small square tile, colored by a few classes of its norm. It should look like a symmetric rug.
- A frog starts at the origin and may only land on primes, jumping at most k (start with sqrt 2). Run a breadth-first search over primes within k of each other and color every prime the frog can reach gold.
Once that works, make it beautiful:
- Run the search one layer per frame so the reachable region spreads like a flood, colored by hop count.
- Add a slider for k that only stops at real lattice distances (sqrt 2, 2, sqrt 5, sqrt 8, sqrt 10 and so on) and reruns the flood. Show how many primes were reached and how far out the frog got.
- Draw a small frog with ellipses and animate it hopping along a shortest path to the farthest prime it can reach.
- Give the background a mosaic look: small tiles with slightly varied colors and thin grout lines.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as Eisenstein primes on a triangular lattice, finding the narrowest gap across the moat, or drawing the frog's island as the union of disks of radius k / 2 around each reached prime.