🌱 SeedDojo

The same few dozen lines run the call-and-card games on this site. Here you build them, then break them.

Step 1 · Commit, then reveal

The caller shuffles the balls from a secret seed and publishes a hash of the call order before the game. After the game she reveals the seed. Anyone can re-shuffle and check the hash matches — so she could not have changed the order halfway.

This uses a simple hash so it runs anywhere. Real protocols use a cryptographic hash; the idea is the same.

Step 2 · Bug one: modulo bias

To pick a number from 0–5 you might take a random byte (0–255) and use byte % 6. Count how often each answer can come up:

256 is not a multiple of 6, so four answers get one extra way to happen. The engine here draws a fraction and scales it instead.

Step 3 · Bug two: a seed that is too small

The birthday problem: with only 65,536 possible cards, a print run of about 300 already has an even chance of two identical ones.