ATTRACT MODE
HOW TO DRAW A PROGRAM.
Programs have structure.
Programs are written line by line, but their parts form a connected structure. Functions, branches, values and references work together. A name links distant parts of the code, and a condition changes the path a calculation takes.
codeimage.io gives that structure a visual form. Defined symbols and structural data make an image that can be read back into a program.
Images have a grammar, too.
A parser identifies a program’s nodes and values. codeimage.io arranges them according to fixed rules, so symbols, relationships and values fit together as one program. During decoding, it reconstructs the canonical image from that structure and checks it against the original PNG.
For supported code, the image alone recovers executable source in a canonical form. A matching exact-recovery key restores the original source byte for byte, including its formatting and comments. The key carries that original text separately from the image.
Revise several parts in a shared state.
Consider a small function that keeps a number within a range. Its comparisons and return values must agree on the same lower and upper bounds. A change to one part can call for changes elsewhere.
The approach we’re exploring treats program structure as a shared state. During training, parts of a structure would be masked so the model learns to fill them from the surrounding structure and a specification. Generation then proceeds through repeated proposals and checks. The model proposes candidates for several positions together. The process checks syntax and references, then masks and revises the parts that still need work. The aim is to bring the structure together over several rounds.
Mask-Predict explores this pattern of filling gaps and revisiting uncertain parts in translation. DiffuCoder studies masked generation and refinement for code. These approaches give us a starting point for exploring joint revision of program structure.
From symbols to a precise image.
Our first experiments will ask a model to propose the symbols, values and references that describe a small program. The plan is to validate each candidate, express it as supported source, and pass it through the existing encoding path into the code image format.
The renderer then applies the defined colors and coordinates, lays out the pages and calculates the verification data. Proposing a structure and recording it as an exact image each get the tools suited to the task.
Check what the program does.
We will evaluate this research by checking whether the recovered program solves the intended problem. We plan to begin with small functions whose inputs and expected behavior are explicit, then test boundary cases and problems with different structures. For a small, finite input domain, every possible input can be compared with its expected result.
Synchromesh shows how explicit syntax, scope and type constraints can guide code generation. EvalPlus shows why behavior needs its own thorough tests, with additional inputs exposing errors that smaller test sets miss.
We also plan to compare text, linear structures, graphs and grids carrying the same information. Under the same budget, we’ll measure which representations reduce errors and which revision strategies use less computation. Those results will guide the next design.
The next step starts small.
codeimage.io already provides the foundation for turning programs into images and recovering them as code. Our next research step is to build and revise structures together on that foundation. We’ll start with small functions and clear rules, then use measured results to guide work on larger structures and tasks.
We are preparing related papers at CSK on program representation, structural generation and behavioral evaluation.
Explore the research topics