Idea · Oct 4, 2026
Brick by Constraint
A multi-week graph algorithms assignment: students turn a voxel shape into a buildable LEGO model, using union-find for connectivity, a search over brick layouts, and a stability check, then export a real LDraw file.
What it would do
Inspired by the Show HN open-source LEGO AI generator (ldraw-nova), this assignment sequence uses brick building as a concrete setting for graphs, search and optimization. Students start from a voxelized shape (provided .vox files or a simple heightmap) and must cover each layer with standard bricks (1x1 to 2x8). Milestone 1 builds a layer-by-layer greedy tiler and exports LDraw so the result renders in a three.js viewer. Milestone 2 models stud connections as a graph and uses union-find to detect pieces that float or split into disconnected components. Milestone 3 improves the layout with local search or simulated annealing, rewarding staggered seams across layers (the way real builders interlock bricks) and penalizing brick count. Milestone 4 adds a simple load-path stability check (does every brick have a supported path to the ground?) and generates step-by-step building instructions by topological ordering. An optional extension asks an LLM to propose a shape from a text prompt, with the student's solver deciding whether it is buildable.
Key features
- Voxel import (.vox or heightmap) and a three.js LDraw viewer for instant visual feedback
- Greedy per-layer brick tiler as a baseline with brick-count and seam metrics
- Union-find connectivity check that highlights floating and disconnected pieces
- Local search or simulated annealing to stagger seams and cut brick count
- Support-graph stability check and auto-generated build steps via topological sort
- Autograder with hidden shapes scoring validity, connectivity, brick count and seam quality