A scenario here means a repeatable loop: reset a task → run N programs → score / log.
uv run python examples/02_list_environments.py --throughput
uv run python examples/02_list_environments.py --search scienceCommon starters:
| Env ID | Goal sketch |
|---|---|
iron_ore_throughput |
Automate 16 iron ore / 60s |
iron_plate_throughput |
Automate 16 iron plate / 60s |
automation_science_pack_throughput |
Red science automation |
open_play |
Maximize production score |
Use when validating the environment or collecting expert demos.
from dspy_factorio.env import make_env, reset_env, step_code, obs_text
STEPS = [
"iron = nearest(Resource.IronOre); print(iron); move_to(iron)",
"drill = place_entity(entity=Prototype.BurnerMiningDrill, position=iron, direction=Direction.NORTH); print(drill)",
]
env = make_env("iron_ore_throughput", run_idx=0)
reset_env(env)
for code in STEPS:
obs, reward, done, trunc, info = step_code(env, code)
print(obs_text(obs), reward)
env.close()See examples/03_scripted_miner.py.
Tips
- Keep each step small and printable.
- Call
move_to(iron)(ormove_to(position=iron)) beforeplace_entitywhen the patch is far from the player (max place distance is ~10). Nevermove_to(pos=...). - Use
Resource.*/Prototype.*enums — string names raise AttributeError inside FLE. - Persist
info["output_game_state"]if you need restore/resume later. - Failures in Lua/Python show up in
raw_text— treat them as observations, not process crashes.
bootstrap inventory+iron → build_agent() → Python program → env.step
See examples/04_dspy_agent_loop.py. Baseline only — no teleprompting, no --load.
Design knobs: --steps, model, observation truncation, API_HINT.
For compiled GEPA agents use 07 (train) + 08 (run) — GEPA_STARTER.md.
RLM sandbox → run_factorio(code) tool → Factorio → REPL → SUBMIT
One RLM call explores with Deno/Pyodide Python and a host tool that steps FLE. Best for error-fixing / probe-then-act. Same fueled-drill milestone as Flex. Tutorial: RLM_STARTER.md (examples/11_dspy_rlm_miner.py). Needs Deno installed.
12 baseline Flex outer loop (intro)
13a play Factorio → demos → GEPA rewrites module_src
13b load learned Flex → same drill goal
Same drill goal as RLM. Tutorial: FLEX_STARTER.md (12 / 13a / 13b). Needs Deno.
Use for comparable benchmarks and logging:
uv run python examples/06_run_inspect_eval.py --env-id iron_ore_throughput --steps 64With one Factorio container always pass --epochs 1.
- Copy
examples/03_scripted_miner.py - Change
STEPS(or callpropose_program) - Log
(step, code, raw_text, reward)to JSONL under.fle/runs/ - Feed good trajectories into
examples/05_optimize_agent.pyas DSPy examples
scripted baseline works?
│
▼
collect few successful trajectories
│
▼
DSPy BootstrapFewShot (offline)
│
▼
agent loop on live env
│
▼
inspect-eval for longer rollouts
Throughput tasks reward production toward a quota. Short Hello World runs often score 0.0 — that is normal until automation actually runs for the evaluation window (sleep, belts, fueled drills, etc.).