Skip to content

A micro JS implementation of the Mulberry32 seedable pseudorandom number generator.

License

Notifications You must be signed in to change notification settings

wout/prng.onchain.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prng.onchain.js

A micro JS implementation (112 bytes) of the Mulberry32 pseudorandom number generator.

This library is intended for use in environments where the available storage space is very limited; like blockchains for example. Everything is stripped down to the bare essentials.

GitHub tag (latest SemVer)

Usage

// Initialize a random generator for a given seed value
let rand = Pr.ng(1234)
rand()
// => 0.07329497812315822
rand()
// => 0.7034119898453355
rand()
// => 0.9028560190927237

// Re-initialize to start the same sequence again using the same seed value
rand = Pr.ng(1234)
rand()
// => 0.07329497812315822
rand()
// => 0.7034119898453355
rand()
// => 0.9028560190927237

Acknowledgements

This implementation is borrowed from here and here.

License

prng.onchain.js is licensed under the terms of the MIT License.

About

A micro JS implementation of the Mulberry32 seedable pseudorandom number generator.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published