Coding Toys (Insomnia Edition)

Abstract

Problem: How should game developers spend their spare time to grow their skills and test ideas?

Approach: Tim Cain shares the small "coding toys" he builds during bouts of insomnia β€” throwaway prototypes in Unity that scratch a creative itch and force him to learn new things.

Findings: Building small, unfinished projects ("toys") is one of the most effective ways to expand your skill set, test game ideas quickly, and learn to edit your own designs. Two examples β€” a Yahtzee-style dice combat game and a 3D random dungeon generator β€” illustrate the pattern.

Key insight: The goal isn't to ship a product; it's to pull an idea out of your head, realize it in code, and learn something you wouldn't have learned on a production project.

Source: https://www.youtube.com/watch?v=mHMFG8uvOb0

Context

Tim Cain records this video at 3 AM during a bout of insomnia. He uses these sleepless hours productively by building small prototypes in Unity β€” what he calls "coding toys." He has previously shown his Space Raiders game (a riff on Atari's Star Raiders from the 1970s) and a GURPS character editor that directly led into the creation of Fallout.

Toy 1: Dungeons and Dices

Tim built a physics-based dice roller in Unity, starting with six-sided dice models in different colors. Once the rolling worked, he turned it into a small game called Dungeons and Dices:

  • You pick a character class that grants one special ability (e.g., the Thief can auto-complete a roll missing one die)
  • You roll dice and arrange them in Yahtzee-style patterns (full house, all same color, etc.) to attack monsters
  • Monsters deal damage every round you haven't killed them, creating time pressure
  • Defense cards must be filled before attack cards, adding tactical decisions
  • Killing monsters grants XP and restores health

Toy 2: Random Dungeon Generator

Tim's second toy is a procedural dungeon generator that produces explorable 3D environments:

The Algorithm

  1. Start with a flat 2D surface (think graph paper)
  2. Drop random rectangles (rooms) with random width and height β€” discard any that overlap existing rooms
  3. Repeat ~100 times until 10–20 rooms exist
  4. Treat rooms as nodes on a graph; add edges between all pairs
  5. Use Dijkstra's algorithm (Tim's description β€” likely Prim's or Kruskal's for MST) to find the minimum spanning tree, giving the minimum set of hallways connecting all rooms
  6. Add back some extra edges so multiple paths exist (not just a single tree)

From 2D to 3D

The flat layout converts directly into a 3D Unity scene: rooms become floors, room boundaries become walls, and hallways are narrow floor surfaces with walls on each side. Tim added Unity lighting and basic first-person exploration. Doors were figured out but not yet implemented β€” "these are just little toys."

Why Build Toys

Tim's core argument for building throwaway prototypes:

  • You learn things production work won't teach you. The GURPS character editor forced him to learn Super VGA modes in the 1990s, which directly informed his next game. His Unity toys forced him to learn Unity UI, physics, gravity, friction, and lighting β€” things he never had to touch on Pillars of Eternity or Tyranny.
  • It kicks you out of your comfort zone. On large team projects, specialists handle things you never see. Solo toys force you into every corner of the engine.
  • It teaches you to edit your own ideas. Not every idea survives contact with implementation. Building it quickly reveals whether it's good or not β€” a skill Tim says took him a long time to develop.
  • Toys can become real games. The GURPS character editor led to Fallout. "You never know where one of these toys is gonna lead."

Advice

Tim recommends every aspiring game developer pick up an engine β€” Unity, Unreal, GameSalad, or any of the many available options β€” learn it, and use it to realize ideas. The goal isn't polish; it's to hone your skills and get ideas out of your head. At minimum, you'll expand your abilities. At best, you'll stumble into your next game.