Learnings from Vibecoding #2
In Shoot the Serif game, i need to mix the fonts. Some are serif, some are sans serif.
At first, I tried to place each font manually. It was slow, boring, and I felt like a headless chicken.
Then I found Fisher-Yates shuffle.
Here's how it works:
Let's say you have a list of fonts:
Serif: Times New Roman, Georgia, Garamond Sans serif: Arial, Helvetica, Verdana
All together: Times New Roman, Georgia, Garamond, Arial, Helvetica, Verdana You don't want them in order. You want them mixed like cards!
🎲 Fisher-Yates Shuffle:
- Pretend the fonts are cards on a table
- Start from the last card
- Pick a random card from the ones still on the table (including the one you're at)
- Swap them
- Move to the next card back and repeat
- Keep going until the first card
Now every font can appear in any spot.
When to use it:
Whenever you want to mix things fairly and randomly:
- Fonts in a game
- Levels in a game
- Cards
- Quiz questions
- Anything you want shuffled
Wanna shoot serif fonts?