{"id":31896082,"url":"https://github.com/thejavaguy/rng","last_synced_at":"2026-07-03T00:33:15.975Z","repository":{"id":57740945,"uuid":"58826341","full_name":"TheJavaGuy/rng","owner":"TheJavaGuy","description":"Implementation of several (pseudo) random number generators (RNGs) which have better characteristics than Java's built in generator","archived":false,"fork":false,"pushed_at":"2020-10-13T07:46:36.000Z","size":103,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-05T00:49:17.302Z","etag":null,"topics":["java","rng"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheJavaGuy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-14T19:31:27.000Z","updated_at":"2024-06-03T10:48:34.000Z","dependencies_parsed_at":"2022-09-06T23:30:53.887Z","dependency_job_id":null,"html_url":"https://github.com/TheJavaGuy/rng","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/TheJavaGuy/rng","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheJavaGuy%2Frng","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheJavaGuy%2Frng/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheJavaGuy%2Frng/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheJavaGuy%2Frng/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheJavaGuy","download_url":"https://codeload.github.com/TheJavaGuy/rng/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheJavaGuy%2Frng/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014615,"owners_count":26085556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","rng"],"created_at":"2025-10-13T10:56:50.670Z","updated_at":"2025-10-13T10:57:09.625Z","avatar_url":"https://github.com/TheJavaGuy.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 1. About rng\nrng 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. \n# 2. Features\nWithin rng you'll find the following generators (in alphabetical order):\n* [Complementary multiply with carry (CMWC)][gen-cmwc]\n* [Mersenne Twister 19937][gen-mt]\n* [R250][gen-gfsr]\n* [R250/521][gen-gfsr]\n* [Xorshift Plus][gen-xorshiftplus]\n\nAll implemented generators share the same interface which makes them totally interchangeable - if you start using one of them but then want to switch to another, you'll have to change only one line of code.\n# 3. Installation\nThe easiest and recommended way to install rng is via your favorite build tool (i.e. Maven or Gradle):\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.thejavaguy\u003c/groupId\u003e\n    \u003cartifactId\u003erng\u003c/artifactId\u003e\n    \u003cversion\u003e0.2.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n```\ncompile group: 'org.thejavaguy', name: 'rng', version: '0.2.0'\n```\nIf you want to build the jar files (with code, javadoc and sources) yourself, you can do that easily:\n```bash\n$ git clone git@github.com:TheJavaGuy/rng.git\n$ cd rng/\n$ mvn clean package -Prng\n$ ls -alF target | grep rng\n```\n# 4. Usage examples\nUsing 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.\n## 4.1 Instantiating a generator\nBefore obtaining pseudo-random numbers, you have to create a generator object:\n```java\nPRNG.Smart generator = new MersenneTwister.Smart(new MersenneTwister());\n```\nIn a similar way you would instantiate an object for some other generator, e.g.\n```java\nPRNG.Smart generator = new XorshiftPlus.Smart(new XorshiftPlus());\n```\n## 4.2 Generating an integer in given range\nThis 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):\n```java\nIntRange sixSidedDie = new IntRange(1, 6);\nint dots = generator.nextInt(sixSidedDie);\n```\nThis 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.\n## 4.3 Generating a double in range [0,1)\n```java\ndouble number = generator.nextDouble();\n```\n## 4.4 Generating various primitive values\nIt's super easy to generate ```boolean```, ```byte```, ```short``` and ```char``` values too:\n```java\nboolean coinToss = generator.nextBoolean();\nbyte colorIndex = generator.nextByte();\nshort tetrisScore = generator.nextShort();\nchar letter = generator.nextChar();\n```\n# 5. How to contribute\nAdditional 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.\n# 6. License\nrng is licensed under [GPLv3][gpl] license.\n# 7. Credits for previous work\nI would like to say a big thank you to the following people - authors of generators implemented in rng project:\n* [Complementary multiply with carry (CMWC)][gen-cmwc] George Marsaglia\n* [Mersenne Twister 19937][gen-mt] Makoto Matsumoto and Takuji Nishimura\n* [R250][gen-gfsr] Scott Kirkpatrick and Erich Stoll\n* [R250/521][gen-gfsr] Scott Kirkpatrick and Erich Stoll\n* [Xorshift Plus][gen-xorshiftplus] George Marsaglia\n\n# 8. How to contact author\nIf 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.\n\n[gen-cmwc]: https://en.wikipedia.org/wiki/Multiply-with-carry#Complementary-multiply-with-carry_generators\n[gen-mt]: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html\n[gen-gfsr]: https://www.unf.edu/~cwinton/html/cop4300/s09/class.notes/VLP-RNGs.pdf\n[gen-xorshiftplus]: https://en.wikipedia.org/wiki/Xorshift#xorshift.2B\n[gpl]: https://www.gnu.org/licenses/gpl-3.0.html\n[rngissues]: https://github.com/TheJavaGuy/rng/issues\n[twitterhandle]: https://twitter.com/_The_Java_Guy_\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthejavaguy%2Frng","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthejavaguy%2Frng","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthejavaguy%2Frng/lists"}