factoriax.analysis.curriculum_strip#

Render a graded-achievement curriculum as a horizontal phase strip.

Public surface:

  • AchievementSpec: plain-Python achievement-bit record.

  • StripLayout: geometry constants.

  • render(): top-level entry. It consumes a sequence of specs plus a phase->hex palette, and writes a PNG.

This module owns no color scheme. phase_palette is a necessary argument. The caller therefore sets the look of each phase, and two reports can style the same curriculum differently.

Internally the renderer is broken into focused helpers: cell-position computation, per-cell drawing, phase-label drawing, and the dashed hand-vs-automation boundary. Same decomposition discipline as factoriax.analysis.recipe_graph.

class factoriax.analysis.curriculum_strip.AchievementSpec(bit: int, name: str, phase: str, hand_craftable: bool)#

One bit in the curriculum.

This mirrors the per-bit metadata of the engine, but holds plain Python types. A caller can therefore draw the strip from a JSON dump without an import of the JAX-backed engine module.

bit#

The index of this achievement in the achievement mask. It is also the large number drawn in the cell.

Type:

int

name#

The short label under the number. Long names overflow the cell, because nothing truncates them.

Type:

str

phase#

The name of the curriculum phase. Cells with the same phase must be next to each other in the sequence given to render(). The phase label spans from the first cell of a phase to the last.

Type:

str

hand_craftable#

True when a player can reach this achievement by hand. The switch from True to False draws the dashed boundary.

Type:

bool

class factoriax.analysis.curriculum_strip.StripLayout(cell_w: float = 1.6, cell_h: float = 1.1, gap: float = 0.05, phase_gap: float = 0.45, boundary_dash_extension: float = 0.35, fallback_color: str = '#cccccc', stroke_darken: float = 0.45)#

Geometry constants for the curriculum strip render.

factoriax.analysis.curriculum_strip.render(achievements: Sequence[AchievementSpec], out_path: Path | str, *, phase_palette: Mapping[str, str], layout: StripLayout | None = None) → Path#

Draw the curriculum strip and return the path of the new file.

Parameters:
  • achievements – The bit specs, in draw order. The strip keeps that order. Two rules apply to it. Cells of one phase must be next to each other, and every hand-craftable bit must come before every automation bit. An empty sequence raises IndexError.

  • out_path – Where to write the image. The extension sets the format, and matplotlib accepts PNG and SVG among others. Missing parent directories are created.

  • phase_palette – {phase_name: hex}. A phase absent from this map gets StripLayout.fallback_color and no warning.

  • layout – Geometry constants, or None for the defaults.

Returns:

out_path as a Path, after the write.

Return type:

pathlib.Path

Notes

The function writes a file and closes its own figure.