The PRNG Trap in Browser Simulations: Why Same-Seed Reproducibility Fails Across Language Boundaries and a Pattern That Works
Diana Ţicudean · Zenodo (CERN European Organization for Nuclear Research) · 2026
Interactive browser simulations typically use seeded pseudorandom number generators (PRNGs) to make runs reproducible. A common and consequential error arises when a simulation implemented in JavaScript is documented or verified using a Python reimplementation sharing the same seed: the two environments use different PRNG algorithms (mulberry32 in JavaScript versus Mersenne Twister in Python), causing them to produce entirely different number sequences even for identical seed values, parameters, and step counts. This note demonstrates the mismatch quantitatively using a minimal 20-node preferential-attachment graph model, showing that the two simulation trajectories diverge immediately and irreconcilably. We introduce a deterministic step-count pattern - Reset to reseed from a fixed integer, then Run to step N and auto-pause - that makes browser simulations reproducible on their own terms without requiring cross-language coordination. The pattern is demonstrated in an interactive Observable notebook with all source code openly available.