You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-8Lines changed: 15 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# 1. About rng
2
-
rng is an implementation of several well-known pseudo-random number generators which have far better characteristics than Java's built-in generator.
2
+
rng is an implementation of several well-known pseudo-random number generators which have far better characteristics than Java's built-in generator. rng can be used for simulations, games (dice rolling, shuffling of playing cards etc.) or for any other application where security is not paramount. Specifically, it should **never** be used for cryptographically secure applications.
3
3
# 2. Features
4
4
Within rng you'll find the following generators (in alphabetical order):
5
5
*[Complementary multiply with carry (CMWC)][gen-cmwc]
@@ -29,8 +29,9 @@ $ mvn clean package -Prng
29
29
$ ls -alF target | grep rng
30
30
```
31
31
# 4. Usage examples
32
-
Using any of the generators is super easy. You just need to create an object and then request random number in the range you need.
32
+
Using any of the generators is super easy. You just need to create a generator object and then request a random number in the range you need.
33
33
## 4.1 Instantiating a generator
34
+
Before obtaining pseudo-random numbers, you have to create a generator object:
This is probably the most common operation with the generator. To generate an integer you always have to specify a _range_ (i.e. lower and upper bound of a number):
42
44
```java
43
-
IntRangerange=newIntRange(1, 6);
44
-
introll= generator.nextInt(range);
45
+
IntRangesixSidedDie=newIntRange(1, 6);
46
+
intdots= generator.nextInt(sixSidedDie);
45
47
```
46
-
```IntRange``` class is constant (immutable) so you can share it's instances freely.
48
+
This may look a bit verbose, but actually makes your code's intention very explicit. ```IntRange``` class is constant (immutable) so you can share its instances freely.
If you spot an error or you think you can add some feature to rng just fork the project and make a pull request.
62
+
Additional generators can be easily added. There is only one requirement: every generator must implement the ```PRNG``` interface. This interface has only one method ```int nextInt();``` which must return integer in the whole range, i.e. ```[Integer.MIN_VALUE, Integer.MAX_VALUE]```. And that's it! All the heavy lifting afterwards is done automatically by the ```PRNG.Smart``` class. If you know how to implement some other generator or believe there's a bug somewhere, please fork the project, change/add what you want and make a pull request.
62
63
# 6. License
63
64
rng is licensed under [GPLv3][gpl] license.
64
65
# 7. Credits for previous work
65
-
TBD
66
+
I would like to say a big thank you to the following people - authors of generators implemented in rng project:
67
+
*[Complementary multiply with carry (CMWC)][gen-cmwc] George Marsaglia
68
+
*[Mersenne Twister 19937][gen-mt] Makoto Matsumoto and Takuji Nishimura
69
+
*[R250][gen-gfsr] Scott Kirkpatrick and Erich Stoll
70
+
*[R250/521][gen-gfsr] Scott Kirkpatrick and Erich Stoll
71
+
*[Xorshift Plus][gen-xorshiftplus] George Marsaglia
72
+
66
73
# 8. How to contact author
67
74
If you have a question or issue with rng itself please use [Issues][rngissues] link. If you want to talk about anything else, I'm [@\_The\_Java\_Guy\_][twitterhandle] on Twitter.
0 commit comments