Split white light with rutile prisms to light colored targets. A search AI plays.
The beam is twelve thin rays, one per wavelength, traced with exact geometry. Mirrors reflect, splitters send half each way, crown glass prisms turn the beam by total internal reflection, and 30 degree rutile wedges refract it with rutile's measured dispersion, six times diamond's, so white light fans into a wide spectrum. A target only lights when most of what reaches it is its own color, so the rainbow is the mechanic. Levels are generated from a seed: pieces are placed on the beam, targets go where nearly pure colors land, walls fill cells the light never crosses, and the pieces go back in your tray. In attract mode a beam search solver plays, trying every piece and rotation on the cells the light touches and keeping the boards whose colors come closest to their targets. The attract loop opens on a later three-target level, where one fan lights red, green and blue at once.
Try it. Drag pieces from the tray onto the table, click a piece to rotate it (right-click or Shift-click turns it back) and drag it off the table to return it. Press Solve or the space bar to watch the solver search, Reset or R to clear the board, and Next or N for a new level. Your own game starts at level 1, and levels never run out.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a light puzzle game with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a canvas that fills the window and stays sharp on high-DPI screens. Draw a dark 10 by 7 grid as the table, a light source on the left edge, a few wall blocks and one round target.
- Let the player drag mirrors from a tray onto empty cells and click them to rotate in 22.5 degree steps.
- Trace the beam every time the board changes: march a ray from the source, find the nearest mirror segment, wall or target it hits, reflect off mirrors, and stop at walls. Draw the path as a glowing line. Light the target when the beam reaches it, and show a little celebration when every target is lit.
Once that works, make it beautiful:
- Trace the beam as about 12 separate wavelengths, each with its own color. Add a triangular prism piece that refracts with Snell's law and an index that rises toward blue (a Cauchy formula is fine), so white light fans into a spectrum.
- Give targets colors, and only light a red target when the light reaching it is mostly red. Now the spectrum is the puzzle.
- Draw the light with globalCompositeOperation = "lighter" and a blurred glow pass.
- Write a few levels by placing pieces yourself, tracing, and putting targets where pure colors land.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as beam splitters and color filters, generating endless levels, or a solver that searches for the answer.