# Math.random library is not random (help) (SOLVED)

**URL:** <https://forum.defold.com/t/math-random-library-is-not-random-help-solved/80118>\
**Category:** Bugs\
**Created:** [March 24, 2025, 12:44pm UTC](https://forum.defold.com/t/math-random-library-is-not-random-help-solved/80118 "2025-03-24T12:44:55Z")\
**Posts on this page:** 1\
**Showing post:** 25

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [March 28, 2025, 9:18pm UTC](https://forum.defold.com/t/math-random-library-is-not-random-help-solved/80118/25 "2025-03-28T21:18:28Z")

</div>

It’s not Defold’s design choice, it’s Lua’s (and many other languages):

> **[Programming in Lua : 18](https://www.lua.org/pil/18.html)**

Alternatively, you can check out the Native Extension with PCG random generation (notice, it also has a `.seed()` function):

> **[GitHub - selimanac/defold-random: PCG Random Number Generator Native Extension for...](https://github.com/selimanac/defold-random)**
>
> PCG Random Number Generator Native Extension for the Defold Game Engine

Or “Defold-RNG” with both PCG and MT:

> **[GitHub - alchimystic/defold-rng: Multi-algorithm Random Number Generator Native...](https://github.com/alchimystic/defold-rng)**
>
> Multi-algorithm Random Number Generator Native Extension for the Defold Game Engine

Or “Dicebag” module (also with `.set_up_rng()` function):

> **[GitHub - 8bitskull/dicebag: Dicebag is a Defold extension containing...](https://github.com/8bitskull/dicebag)**
>
> Dicebag is a Defold extension containing probability functions designed specifically for games.

Regarding one case, where seed is used for generating worlds - yeah, it comes to my mind immediately: 😃

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/c/2/c2e8af7228c0acfd917f2729365ffdaac1087963.png)

As you can see, if no seed is provided the default is “random”, so I get your confusion and I believe it could be done in the very same way, but in case of pseudo-random generators it was always on developer to decide which seed to provide, the program doesn’t assume it for us, it’s weird, I agree 😃

---

_[View the full topic](https://forum.defold.com/t/math-random-library-is-not-random-help-solved/80118)._
