Z-error edge Anyon (Av=−1) Periodic seam (wraps)

Toric Code on a Flat Torus Chart (2D)

This 2D companion to the 3D toric-code simulator drops the curved-surface embedding in favor of the flat, periodic-boundary chart the toric code is actually defined on: qubits sit on every edge of an L×L grid whose top and bottom rows are identified, and whose left and right columns are identified, exactly like the classic "screen wraps around" arcade convention — drawn here as dashed stub pairs at the border instead of a hidden camera trick. Clicking an edge applies a Pauli-Z error and creates a pair of anyon defects wherever the local vertex stabilizer flips parity; extend the error string edge by edge, including straight through a periodic seam, and watch the anyon hop while the string's interior stays invisible to every stabilizer check. The key demonstration carries over unchanged: a loop that winds all the way around a periodic direction annihilates its anyons and passes every local syndrome check exactly like vacuum, yet silently flips one of the code's two logical qubits — a live winding-number readout, computed from the same boolean error arrays as the 3D version, tracks this invisible logical error the instant it happens.