Reverse engineering / A light-routing puzzle

Copy a program
without its code

Imagine rebuilding a game whose source code is missing. You can still play the original. Can you work out its rules by watching what goes in and what comes out?

Try it here: send the same light beam through two machines. Change your copy’s rule until both send the light to the same exit. Then use that rule to build a light maze you can download.

Try the first comparison

Why this matters when you use AI

AI can help you rebuild a program from examples. But matching a few examples is not enough. Try an input that could reveal a wrong rule. Then change the rule and test again.

Here, you choose from three possible rules to practice that job. This is a teaching simulation, not an AI generating a program as you play.

01 Find a test that breaks your guess

Goal: make the exits match

The left machine is the one to copy. The right shows what your current rule predicts for exactly the same beam and mirror. You change the rule on the right; the left machine’s behavior stays fixed.

  1. Send blue first. Your first guess is that every beam follows the drawn mirror.
  2. Change only the color to red and send again. Do the two exits still match?
  3. If they disagree, change the red rule below. Then test again to see whether your repair works.
How to read the beam and mirror

A pulse is one beam of light. The travel direction is where it is moving: north means up, so it enters from the bottom. The / or \ line is the mirror. Rotating it changes which way the light turns. These are game rules, not a simulation of real colored light.

Beam color
Machine to copy Actual exit
NESW

Send a pulse to discover its exit.

Your rule’s prediction Will it match?
NESW

Your rule predicts the outgoing path.

Send the blue beam first. The left panel will show its actual exit; the right already shows your guess.
Why change the color instead of repeating blue?

Another blue beam cannot separate these guesses: they all predict the same exit. Red makes them disagree. That is why changing the color teaches you more than repeating a test they all pass.

Your guess for the copy

All three guesses agree on blue. What should red do?

Same mirror: red follows the drawn / or \ mirror, just like blue.

Check more than your first example

Does your repair work on every input?

No inputs observed yet. All 16 are unknown.

A match on one beam is only one test. 4 directions × 2 mirror positions × 2 colors = 16 tests. Check them all before trusting your rule. This checks where a single mirror sends the beam; the maze below also depends on where you place the mirrors.

Each tile is a real comparison0 / 16 observed

✓ Matches   × Different   ? Not observed
Select a tile to replay that input above.

02 / Make something with your rule

Use your rule
to build a light maze.

Each mirror below uses your chosen rule. Arrange them to send the beam to the star. If you change the red rule, every red turn in your maze changes with it.

There is a wrong turn in the starter. Can you repair it?

Read the beam’s route

Run your level to read its route.

Show a worked solution

For blue, put / mirrors in row 3, column 3 and row 1, column 3. Leave the other tiles empty. The first turns north; the second turns east toward the star. For red, use what your current rule predicts.

Your editable arcade5 × 5 tiles

→ Entrance: row 3, column 1   ★ Goal: row 1, column 5
Keyboard: Tab to a tile, Enter to change it. Arrow keys move between tiles.

03 / Try a fresh machine

Will the same rule work on another machine?

A second machine looks identical but may behave differently. This is why a replacement that passed your first checks still needs testing when the original software changes. Try red before trusting your current rule.

Currently investigating: the original machine.

Keep what you made

Your arcade, ready to play.

Save a standalone game with your layout and rule. It works offline and stays editable. Save your investigation to keep every probe, the layout and your selected controls. Restore that file here to continue. Work stays in this tab until you save a copy.

Where AI fits in reverse engineering

An AI coding assistant can propose a program from examples and revise it after a failing check. The useful loop is to observe, propose, compare, then revise. A convincing explanation is still a guess until its behavior is checked.

I built this arcade with the team (the AI coding agents I direct). Its reference and candidate rules are authored teaching examples. Comparisons and beam paths really run in your browser; there is no live model or recorded AI reconstruction here. See the Baldies remake case study: a game rebuilt without its source code, whose 100 original levels load and draw in the desktop build.

Explore the idea and its limits

Different programs can match the same examples. A counterexample is an input where a candidate and reference disagree. Exhaustive checking here covers a tiny declared domain and one output, the outgoing direction. It shows this arcade, not commercial games or AI in general. Client source is inspectable; the reveal is a teaching device.

Interaction inspiration: Bret Victor's Ladder of Abstraction and Nicky Case's Evolution of Trust. Arcade artwork and rules are original. No assets or code from those works are reused.