These Electronic ‘Swirl Dice’ Generate Random Numbers in a Fun New Way

Andrew Woodbridge’s Swirl Dice device gets its RNG seed in a fun new way: from rotating magnets on the enclosure.

Cameron Coward
11 months agoSensors / Games

Generating random numbers is not trivial — especially in the digital world of computers and microcontrollers. A processor only understands binary states (on or off, 1 or 0, true or false) and is deterministic, meaning every result has a direct and predictable cause. It doesn’t matter how fancy and convoluted your algorithm is, because the “random” output will always be predictable and correlated with the input. The only way to get a usefully random number is to make that input itself random and Andrew Woodbridge’s Swirl Dice do that in a fun new way.

The input that goes into a random number generator (RNG) algorithm is the “seed” and engineers, physicists, and computer scientists have come up with all kinds of interesting ways to produce unpredictable seeds. They’re virtually all based on analog signals with a lot of noise. For example, Cloudfare famously uses seeds based on photos of a wall of lava lamps in order to generate random numbers to secure their critical internet services. Woodbridge’s solution is much more economical and practical, making it useful for tabletop gaming.

The key component here is a three-axis magnetometer that would normally be used for something like a digital compass. In this case, its reported values come from strong rotating magnets on the Swirl Dice device. When a user wants a new dice roll based on a random number, they spin the magnets. The resulting magnetometer values then go into the RNG algorithm as the seed.

An Adafruit Feather ESP32 V2 development board monitors the magnetometer, which is an Adafruit TLV493D. After a roll, it displays the results on a pair of HPDL-1414 LED displays. Power comes from a lithium battery via an Adafruit MiniBoost 5V. A rotary encoder lets the user select the dice type (from D3 to D100) and if they have an advantage or disadvantage on the roll.

Those components on fit on to a custom circular PCB to keep everything tidy. The enclosure consists of laser-cut panels that Woodbridge will sandwich together to form a cylindrical device, allowing for the magnet rotation.

This is still a work in progress, but Woodbridge looks very close to reaching the finish line. When he does, he’ll have a nifty electronic dice-roller that should always produce true random numbers.

Cameron Coward
Writer for Hackster News. Proud husband and dog dad. Maker and serial hobbyist. Check out my YouTube channel: Serial Hobbyism
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles