https://github.com/kchapelier/migl-rng
Micro Game Library : Random number generator (using seedrandom and noisejs)
https://github.com/kchapelier/migl-rng
Last synced: 8 months ago
JSON representation
Micro Game Library : Random number generator (using seedrandom and noisejs)
- Host: GitHub
- URL: https://github.com/kchapelier/migl-rng
- Owner: kchapelier
- License: mit
- Created: 2015-04-02T11:36:58.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-02T11:39:11.000Z (over 10 years ago)
- Last Synced: 2025-02-14T12:55:44.471Z (8 months ago)
- Language: JavaScript
- Size: 97.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# migl-rng
Micro Game Library : Random number generator (using seedrandom and noisejs)
## Features
* Create a random number generator based on a string
* Use seedrandom and noisejs## Basic example
```js
var rng = require('migl-rng');var r = rng.create('Test');
console.log(r.random());
console.log(r.randomBounded(50, 100)); // random bewteen 50 and 100 included
console.log(r.perlin2(1.1, 5.1));
console.log(r.perlin3(1.1, 5.1, 4));
console.log(r.simplex2(1.1, 5.1));
console.log(r.simplex3(1.1, 5.1, 4));
```It is also possible to use a custom hashing function :
```js
var rng = require('migl-rng'),
stringHash = require('string-hash');var r = rng.create('Test', stringHash);
```Or to directly set the seed :
```js
var rng = require('migl-rng');var r = rng.create(12943);
```