Skip to content

Instantly share code, notes, and snippets.

@manthrax
Created June 15, 2020 08:08
Show Gist options
  • Save manthrax/e0e1b8c6d081e5a1ef74721e93bb2f5a to your computer and use it in GitHub Desktop.
Save manthrax/e0e1b8c6d081e5a1ef74721e93bb2f5a to your computer and use it in GitHub Desktop.
js wichmann hill rng.. untested.. drop in replacement for Math.random.. uses zelda ww seed by default
let wichmann_hill_rng = (s1=100,s2=100,s3=100)=>()=>((s1 = (171 * s1) % 30269) / 30269 + (s2 = (172 * s1) % 30307) / 30307 + (s3 = (170 * s1) % 30323) / 30323) % 1
let rng = wichmann_hill_rng()
for (let i = 0; i < 1000; i++) console.log(rng())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment