summaryrefslogtreecommitdiff
path: root/src/node_modules/chance/docs/usage/seed.md
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2021-12-21 16:52:28 +0100
committerMinteck <contact@minteck.org>2021-12-21 16:52:28 +0100
commit46e43f4bde4a35785b4997b81e86cd19f046b69b (patch)
treec53c2f826f777f9d6b2d249dab556feb72a6c3a6 /src/node_modules/chance/docs/usage/seed.md
downloadlangdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.gz
langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.bz2
langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.zip
Commit
Diffstat (limited to 'src/node_modules/chance/docs/usage/seed.md')
-rw-r--r--src/node_modules/chance/docs/usage/seed.md49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/node_modules/chance/docs/usage/seed.md b/src/node_modules/chance/docs/usage/seed.md
new file mode 100644
index 0000000..737a91d
--- /dev/null
+++ b/src/node_modules/chance/docs/usage/seed.md
@@ -0,0 +1,49 @@
+# seed
+
+You can also instantiate your own instance of Chance with a known seed. This is
+useful for creating repeatable results.
+
+```js
+var chance1 = new Chance(12345);
+var chance2 = new Chance(12345);
+
+// These yield the same values, in sequence
+console.log(chance1.random());
+console.log(chance2.random());
+```
+
+Since both copies of Chance had the same seed, they will both generate the same
+random number sequence each time they're called.
+
+This allows for repeatability, if desired.
+
+This is possible because **Chance** is built atop a [Mersenne Twister][mersenne],
+a pseudo-random number generator which produces repeatable results given the same seed.
+
+Optionally provide the seed as a string.
+
+```js
+var chance1 = new Chance("foo");
+var chance2 = new Chance("bar");
+
+// These will be different
+console.log(chance1.random());
+console.log(chance2.random());
+```
+
+Optionally provide multiple arguments as the seed.
+
+```js
+var chance1 = new Chance("hold", "me", "closer");
+var chance2 = new Chance("tony", "danza");
+var chance3 = new Chance("hold", "me", "closer");
+
+// These will be different
+console.log(chance1.random());
+console.log(chance2.random());
+
+// This will be the same as the value from chance1 above
+console.log(chance3.random());
+```
+
+[mersenne]: http://en.wikipedia.org/wiki/Mersenne_twister