Work in progress, and the code is public: github.com/aRandomHumanoid/RLToolpath.

A slicer picks infill by rule. A fixed angle, a fixed density, the same pattern everywhere, regardless of what the part has to carry. For a part that is over-built anyway that is fine, and for one that isn’t it is waste: the material is in there, it just isn’t pointed anywhere useful. This asks whether the toolpath itself can be planned against the loads instead. Slice the mesh, then search over where the infill goes and which direction each bead runs, scoring candidates against the forces the part will actually see.

The catch is that you cannot simply point every bead at its ideal angle. A toolpath has to be printable. Beads have to join into continuous strokes instead of a thousand disconnected segments, the nozzle shouldn’t spend the print travelling between them, layers have to bond, and the region has to actually get covered. Strength, print time and continuity pull against each other, so the whole thing rests on one scoring function: in-plane strength over many load cases, print time, continuity, interlayer bond, and coverage. Every candidate from every method goes through that same evaluator, which is the only reason the numbers below can be compared at all.

On the name: the RL is historical. A policy was trained, imitation warm-start then PPO, but it is frozen on the 0.4 mm grid and is not the active line. What produced these results is searching directly against the evaluator — simulated annealing over single edits, starting from a layout that solves for bead directions up front.

There are two lines of work, on two branches.

Editing a toolpath one window at a time

The first approach keeps the slicer’s structure and improves it edit by edit: anneal over single-window changes, starting from a gradient layout that orients every cell against all the load cases at once.

Fifteen cycles went into working out why the toolpaths barely changed at first. The strength term sat almost entirely in walls that were locked at the clamp edges, so the interior could be rearranged freely without the score noticing. Proposals weren’t aimed at anything. And different starting layouts weren’t being scored on a common footing, so comparisons between them meant nothing. With those fixed, the adaptive mode lowers the aggregate strength index by 9.1% against 0.5% for plain annealing, averaged over 21 load cases on five parts, while print time stays within about 1.3% on four of the five. Alignment between each bead and the direction that cell would most like to be in goes from 0.30 to 0.41.

Bead directions on the bracket across four layouts, with the ideal direction field at right

The useful finding is where the adaptation happens. The gradient start turns every direction field at once; the annealing afterwards mostly buys back continuity. A re-plan that size is out of reach for single-window edits, because each one has to pay its own continuity and layer-bond cost by itself, and almost none of them can.

That same start introduced a bug worth keeping. It laid each infill line only where the density field cleared a threshold and stopped it where the direction field changed, so lines began and ended in mid-air: on some parts 71% of infill path ends touched neither a wall nor another bead. Nothing in the score objected, for two separate reasons — the laminate model bonds every layer perfectly, so a line anchored to nothing carries load as well as one tied into the wall, and the continuity term charged strokes and travel but never asked where an end landed. The model was wrong, not the optimizer.

Free infill line ends, circled, before and after anchoring, on the bracket and hook

Filling the inside with surfaces instead

The second approach gives up editing and changes what infill is. The part is hollowed to its shell and the inside is filled with ribbons: surfaces running through the infill layers whose cut in any single layer is one continuous bead path. Ribbons end against the walls, may cross or bond with each other, and their ends get merged into longer strokes as the toolpaths are generated. A search then deforms the ribbons, and every candidate is laid out as bead paths and scored by the unchanged evaluator.

Ribbon infill on the plate, each colour one continuous bead path

This wins on everything except raw strength. Against the edit-by-edit optimizer’s best, ribbons score 51 to 120 points higher on its own load cases, using a third to a fifth of the strokes and printing 15 to 23% faster. The search starts from straight families and warps them into place.

A straight start deformed by the search into warped ribbons

More interesting is what happens on load cases neither method ever saw. Re-scored on held-out seeds, ribbons move between −16 and +6 points, while the edit-by-edit reference moves between −2 and −38. The edit-by-edit optimizer had been fitting itself to its own set of cases, and the ribbons, having many fewer degrees of freedom to spend, had less to overfit with. The reference still produces the stronger part in absolute terms — 7 to 15% lower on the strength index even on unseen loads — because it places material and direction per cell, where ribbons only control line spacing and a smooth warp. Fewer knobs, better generalisation, lower ceiling.

What this isn’t yet

Strength here is a relative score from a laminate model with placeholder material constants, not a calibrated prediction. Nothing has been printed and pulled. That is deliberate rather than overlooked — the goal so far has been good continuity and sensible strength under a consistent score, and coupon testing is the gate for the parts of the design doc that aren’t built. It does limit what can be claimed: with the placeholder PLA, bead direction only changes compliance by 0.3 to 1.9%, so the stiffness term is a weak lever that real coupon values would likely strengthen.

Both branches are live. The ribbon line is where the interesting results are; the edit-by-edit line is still the stronger part and the reference everything is measured against.