Stream: beginners

Topic: surprising behavior using random number generator


view this post on Zulip Lorentz Lasson (Dec 17 2023 at 18:51):

not sure where a suitable place is to post this, but im definitely a beginner, so maybe here! :)

i am playing around with random number generation and found that the same number kept being generator regardless of what seed i used. not sure if a bug, but definitely surprised me.

i was able to produce this is a minimal example https://github.com/JanCVanB/roc-random/issues/14. i realized i posted in the wrong repo, but the repo for the fork im using (https://github.com/lukewilliamboswell/roc-random) doesn't allow issues

view this post on Zulip Luke Boswell (Dec 17 2023 at 19:47):

Fuxed that, should be able to add issues. This looks like the first one :grinning_face_with_smiling_eyes:

view this post on Zulip Luke Boswell (Dec 17 2023 at 19:50):

I'm not sure how quickly I'll be able to investigate this issue. I'm definitely not familiar with roc random, I just revived @JanCVanB work and packaged it so it was useable.

view this post on Zulip Lorentz Lasson (Dec 17 2023 at 19:58):

ah cool, moved the issue over :+1: no rush at all from my side, i've worked around it

is there a recommended way to generate seeds during runtime? didnt find anything in the docs so just went with Utc.now millis

view this post on Zulip Luke Boswell (Dec 17 2023 at 20:12):

Not sure about reccomend or anything, but I've been using Utc too

view this post on Zulip Luke Boswell (Dec 17 2023 at 20:17):

What platform are you using? Maybe we should add a Task for getting properly random seeds? That's a pretty easy to do if your interested.

view this post on Zulip jan kili (Dec 17 2023 at 20:52):

I've been unavailable to the Roc community for a year or so now, but I'm slowly re-entering! I hope to take a look this week :)

view this post on Zulip jan kili (Dec 17 2023 at 20:53):

I didn't do any work on seed generation, just left that to the consumer - millis sounds reasonable

view this post on Zulip jan kili (Dec 17 2023 at 20:55):

Luke, did I ever get you the permissions/config you wanted? I'm afk today, but I imagine there's some friendly PR from you that I've completely ghosted

view this post on Zulip jan kili (Dec 17 2023 at 20:56):

Lorentz, nice job finding a workaround

view this post on Zulip Lorentz Lasson (Dec 17 2023 at 21:12):

i'm on linux.

a task to get a properly random seed sounds lovely :heart:

view this post on Zulip jan kili (Dec 17 2023 at 21:15):

Unfortunately there's no such thing ;)

view this post on Zulip jan kili (Dec 17 2023 at 21:16):

If you had it, you wouldn't need the library!


Last updated: Jul 06 2025 at 12:14 UTC