{"id":15722540,"url":"https://github.com/thinknathan/defold-prng","last_synced_at":"2025-10-13T09:13:03.120Z","repository":{"id":171160565,"uuid":"647527294","full_name":"thinknathan/defold-prng","owner":"thinknathan","description":"Defold native extension seeded psuedo-random number generator using the Mulberry32 method.","archived":false,"fork":false,"pushed_at":"2025-05-01T16:23:14.000Z","size":247,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-13T12:49:07.697Z","etag":null,"topics":["defold","defold-extension","defold-game-engine","defold-library","defold-native-extension","gamedev"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thinknathan.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-31T01:25:15.000Z","updated_at":"2025-03-01T16:27:16.000Z","dependencies_parsed_at":"2024-03-04T00:25:32.084Z","dependency_job_id":"617d4f66-a7d8-470f-bddb-0229011924bf","html_url":"https://github.com/thinknathan/defold-prng","commit_stats":null,"previous_names":["thinknathan/defold-prng"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/thinknathan/defold-prng","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinknathan%2Fdefold-prng","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinknathan%2Fdefold-prng/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinknathan%2Fdefold-prng/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinknathan%2Fdefold-prng/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinknathan","download_url":"https://codeload.github.com/thinknathan/defold-prng/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinknathan%2Fdefold-prng/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014483,"owners_count":26085535,"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":["defold","defold-extension","defold-game-engine","defold-library","defold-native-extension","gamedev"],"created_at":"2024-10-03T22:08:21.347Z","updated_at":"2025-10-13T09:13:03.077Z","avatar_url":"https://github.com/thinknathan.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"_docs/def-mulberry32-x1.png\" alt=\"Def-Mulberry32\"\u003e\n\n# Mulberry32 PRNG for Defold\n\n[![Build with bob](https://github.com/thinknathan/defold-prng/actions/workflows/bob.yml/badge.svg)](https://github.com/thinknathan/defold-prng/actions/workflows/bob.yml) ![GitHub License](https://img.shields.io/github/license/thinknathan/defold-prng)\n\nThis Defold native extension implements a seeded psuedo-random number generator using the Mulberry32 method.\n\n## Usage\n\n```lua\n-- Set the seed. Must be an integer.\nprng.set_seed(12345)\n\n-- Generate a random float between 0 and 1.\nlocal randomFloat = prng.rand_float()\n\n-- Generate a random integer between 0 and the maximum you provide.\nlocal randomInt = prng.rand_int(5)\n\n-- Flips a coin. Returns 0 or 1.\nlocal coinFlip = prng.coin()\n\n-- Get a card suit. Returns 0, 1, 2, or 3.\nlocal randomCardSuit = prng.suit()\n\n-- Roll one or more dice.\nlocal dice = prng.dice(1, 8)\n\n-- Rolls twice and takes the higher result. More likely to return 1 than 0.\nlocal success = prng.advantage()\n\n-- Rolls twice and takes the lower result. More likely to return 0 than 1.\nlocal success = prng.disadvantage()\n```\n\n## Installation\n\n1. Edit game.project\n2. Add dependency `https://github.com/thinknathan/defold-prng/archive/main.zip` for the current version\n   - Or add a specific [release](https://github.com/thinknathan/defold-prng/releases)\n\n### TypeScript Definitions\n\nThis extension includes types for use with [TypeScript + Defold](https://ts-defold.dev/).\n\n1. Install these types\n\n```bash\nyarn add git+https://git@github.com/thinknathan/defold-prng.git#^1.0.0 -D\n# or\nnpm install git+https://git@github.com/thinknathan/defold-prng.git#^1.0.0 --save-dev\n```\n\n2. Add `defold-prng` to `types` in `tsconfig.json`\n\n```diff\n{\n\t\"compilerOptions\": {\n\t\t\"types\": [\n+\t\t\t\"defold-prng\",\n\t\t],\n\t}\n}\n```\n\n3. Add `node_modules/@types` to `typeRoots` in `tsconfig.json` if it's not already there\n\n```diff\n{\n\t\"compilerOptions\": {\n\t\t\"typeRoots\": [\n+\t\t\t\"node_modules/@types\",\n\t\t],\n\t}\n}\n```\n\n## Alternatives\n\nSee [SplitMix64](https://github.com/indiesoftby/defold-splitmix64), [PCG Random](https://github.com/selimanac/defold-random) and [rand16](https://github.com/wmc7n/rand16). Compare [PRNG implementations](https://github.com/bryc/code/blob/master/jshash/PRNGs.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinknathan%2Fdefold-prng","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinknathan%2Fdefold-prng","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinknathan%2Fdefold-prng/lists"}