Play CodeRealm

Shuffle

RANDOMNESS

Loading audio…

Press play to listen along. The line being read lights up as you go.

Show full transcript

Loading transcript…

01 Opening
Shuffle beat 1 of 5

In the corner of the CodeRealm workshop sat a covered cup, and it was, at that exact moment, doing something no one in the room could predict.

Loop had it on the bench in front of a class of squinting kids. It was a plain tumbler, lidded, and when Loop gave it a shake it made a dry, rattling music — a whole crowd of small numbered tokens knocking together in the dark. He held it up so everyone could hear it.

"This is Shuffle," Loop said. "Randomness. Watch closely, because I promise you I don't know what happens next either."

He tipped the cup. A single token slid out onto the bench and rolled to a stop. 4.

"Four," Loop said, as if it were the most ordinary thing in the world. He scooped the token back in, capped the cup, shook it — that rattling music again — and drew once more. 1. Then again, 6. Then 1 a second time.

A kid in the front row leaned forward, frowning. "Do it once more."

Loop did. 3. The kid sat back, a little defeated and a little delighted, because they had genuinely been trying to guess and there had been nothing to grab onto — no pattern, no rhythm, no next-in-line. Just a cup, a shake, and a fresh surprise every single time.

"That," Loop said, "is the whole job. When a program needs something you can't guess ahead of time — a dice roll, a random enemy, a shuffled quiz — you shake Shuffle and draw. A value nobody can see coming. Not the workshop, not you, not even me."

He set the cup down, and it sat there quietly with all its unknown tokens hidden inside, patient and full of surprises.

02 Shuffle
Shuffle beat 2 of 5

Loop noticed a kid at the back who wasn't laughing.

This kid had built a guessing game the week before, and it had gone wrong in the most boring way possible: every time you played it, the "secret" number was 7. Always 7. The first player found it in a run, told everyone, and after that the game was dead. No one could be surprised twice.

"It wasn't broken," the kid said, miserable. "It ran perfectly. It was just... the same. Every time. I made a game that couldn't surprise anybody."

Loop pulled the cup over and set it in front of them.

"You didn't need a bigger machine," Loop said. "You needed one that forgets. Watch." He shook the cup and drew — 5 — capped it, shook, drew again — 2. "It doesn't remember the last draw. It has no favorite number. There's no seven waiting in there for you to trip over. Every draw is fresh."

The kid picked up the cup themselves. Shook it. Drew. 6. Shook. Drew. 1. And something loosened in their chest — the flat, stuck feeling of the same, the same, the same lifting off, replaced by the small rising fizz of I don't know what's next. They shook it a third time just to feel it again.

"See," Loop said gently. "That jumpy, don't-know feeling? That's the thing your game was missing. Not a bug. A surprise."

03 Shuffle
Shuffle beat 3 of 5

The kid brought their game back to the workshop the next morning and set the cup on the bench like it belonged there.

"I want to build it right this time," they said.

Loop didn't ask them to prove anything. He asked one question. "What does randomness give a program?"

The kid didn't answer with words. They wired Shuffle into the guess-a-number game so that each round, the workshop shook the cup and drew a fresh secret token from 1 to 9 — and then they made Loop play it. Loop guessed 4. Wrong; it was 8. They reset. Loop guessed 8 on purpose this time, grinning. Wrong again; it was 2.

"You can't cheat it," the kid said, "because I don't even know what it'll draw. It picks fresh, every round, from the cup."

Loop played three more rounds and lost every guess, and by the end he was laughing.

"You belong here," he said, and set the cup back on the bench beside the kid's game like it had always lived there.

04 Shuffle
Shuffle beat 4 of 5

By afternoon the kid had a little crowd, and one of them wanted a game of their own.

"I need a dice," this new kid said. "For a board game. But I don't get it — how does a cup roll a six?"

The kid who now understood Shuffle pulled the cup over. "Watch. You put six tokens in — 1 to 6. Shake." Rattle. "Draw." 3. "There's your roll. Want a coin flip instead? Two tokens — heads and tails. Want a random cheer? Fill a list with phrases, shuffle it, and draw one. Same idea every time: shake, draw, get a fresh one."

The new kid dropped in the six tokens and drew. 5. Then 5 again.

"Wait — two fives! Is it stuck? Am I due for a low one now?"

The first kid shook their head, remembering exactly how Loop had said it. "That's the honest part. It doesn't keep score. Two fives in a row doesn't make the next draw any less likely to be a five. The cup has no memory and no fairness-debt — it isn't 'saving up' a low number for you. Every draw is fresh and completely on its own."

The new kid drew again, half-braced for a five, and got 1, and the whole small crowd let out a whoa. They played on, and every roll landed like a tiny gift nobody could open early.

05 Closing
Shuffle beat 5 of 5

When the workshop emptied out, the first kid stayed behind with the cup, running their fixed game one more time, alone.

They'd wired it so it drew a fresh secret number and a random cheer and shuffled the questions into a new order. They ran it. 3, a chirped Nice one!, the questions in one order. They ran it again. A different secret, a different cheer, a different order entirely. Same exact code. Brand-new run.

And then it happened: the game surprised them. They'd built every line of it, and it still did something they hadn't seen coming — and they laughed out loud in the empty room, alone, at their own machine.

The cup sat on the bench, lid on, tokens hidden, quietly ready for the next shake. It wasn't thinking. It wasn't feeling lucky. It was just a cup of tokens you shook and drew from, fresh every time. But the kid, watching a thing they'd made astonish them run after run, felt the brightest, jumpiest kind of happy — the delight of not knowing what comes next, of building something alive enough to still amaze the one who built it.

They shook the cup one more time before they left, just to feel that small rising fizz, and drew a 6, and grinned all the way out the door.

Hear it as an audio drama

A short play starring Shuffle, from CodeRealm. Different voices, same idea. Listen any time after you read.

Loading audio…

Read the drama script
  1. Narrator: From Spark and Anvil and CodeRealm — this is Shuffle, in chapter 1 of the CodeRealm cast.
  2. Narrator: This drama uses an AI-generated voice. Voiced via Gemini 2.5.
  3. Narrator: In the corner of the workshop sits a covered cup — a plain lidded tumbler that, when shaken, makes a dry rattling music: a crowd of small numbered tokens knocking together in the dark. This is Shuffle.
  4. Loop: This is Shuffle. Randomness. Watch closely, because I promise I don't know what happens next either.
  5. Narrator: Loop tips the cup. A single token slides out. Four. He scoops it back, caps, shakes, draws again. One. Then six. Then one a second time.
  6. Kid: Do it once more.
  7. Narrator: Three. The kid sits back, a little defeated and a little delighted — genuinely trying to guess, and nothing to grab onto. No pattern, no rhythm, no next-in-line.
  8. Loop: That's the whole job. When a program needs something you can't guess ahead of time — a dice roll, a random enemy, a shuffled quiz — you draw from Shuffle. A value nobody can see coming. Not the workshop, not you, not even me.
  9. Narrator: One kid at the back wasn't laughing. Their guessing game had failed in the most boring way: every time you played, the secret number was seven. Always seven.
  10. Kid: It wasn't broken. It ran perfectly. It was just the same, every time. I made a game that couldn't surprise anybody.
  11. Loop: You didn't need a bigger machine. You needed one that forgets. It doesn't remember the last draw. It has no favorite number. There's no seven waiting in there for you to trip over. Every draw is independent — fresh, on its own.
  12. Narrator: The kid shook the cup, drew six, shook, drew one — and something loosened in their chest, the flat stuck feeling of the-same-the-same-the-same lifting off, replaced by the small rising fizz of I-don't-know-what's-next.
  13. Narrator: By afternoon a new kid wanted dice for a board game, and dropped in six tokens.
  14. Kid: Wait — two fives! Is it stuck? Am I due for a low one now?
  15. Loop: That's the trap almost everyone falls into — the gambler's fallacy. It doesn't keep score. Two fives in a row doesn't make the next draw any less likely to be a five. The cup has no memory and no fairness-debt. It isn't saving up a low number for you. Every draw is independent, completely on its own.
  16. Narrator: The new kid drew again, half-braced for a five, and got one, and the whole small crowd let out a whoa.
  17. Narrator: When the workshop emptied, the first kid ran their fixed game one more time, alone — a fresh secret number, a random cheer, the questions in a new order. Same exact code, brand-new run. And then it happened: the game surprised its own builder. They laughed out loud in the empty room, shook the cup once more just to feel that fizz, drew a six, and grinned all the way out the door.
  18. Narrator: You've been listening to a Spark and Anvil chapter, written by the Spark and Anvil writing team for ages 9 to 14.
  19. Narrator: Apps stay free forever.
  20. Narrator: Curriculum aligned to Computer Science Teachers Association standards.
  21. Narrator: Released under Creative Commons BY-NC-SA 4.0 for educational reuse. Visit Spark and Anvil for the full transcript.

The CodeRealm ensemble

Shuffle is one of the friends in CodeRealm. Each friend shows you one idea by how they act; meet them all and you have the whole subject.

Kids also liked