Algorithm-Arena / weekly-challenge-23-unconventional-randomness

0 stars 0 forks source link

Submission - Web Worker Randomness #1

Open alshakero opened 1 week ago

alshakero commented 1 week ago

This creates a random number from spinning a 512 Web Workers and sends messages to them in parallel.

Sources of entropy

  1. There are 512 workers that run in parallel, each worker is a thread, meaning the OS has to manage all of that (my machine supports 16 threads max), and this generates a lot amount of chaos.
  2. Posting messages to workers is asynchronous, which is unpredictable in how long it takes if you measure in microseconds.

Video

https://github.com/Algorithm-Arena/weekly-challenge-23-unconventional-randomness/assets/17054134/4bb04a24-8526-4dd3-8d1b-0f884c5283c1

Source

https://glitch.com/edit/#!/random-number-generataor

alshakero commented 1 week ago

Dammit, my randomness test was missing an await thus incorrect. I do have collisions! Will fix tomorrow.

Edit: fixed now

alshakero commented 1 week ago

Update: it just occurred to me that uniqueness is not the equivalent of randomness. They don't have to be unique to be random.

I cleaned up the code, simplified it, and moved to Glitch, Codepen was interrupting my loops thinking they were infinite.

I used this tool to measure randomness, and sadly Math.random is much more random than my solution.