Part 2 in the Factory Agent Series: A Visual Walkthrough of Intelligent Control
Before diving into the data backbone and architectural principles that power Factory Agents, we wanted to show you something real — and fun.
What happens when you bring large language models into a living, breathing (virtual) industrial world?
Let us introduce:
Factorio + LLM Agents
An open-ended simulation of intelligent control systems, where LLM agents perceive, reason, and act inside a virtual factory.
1. Welcome to the World of Factorio
Before we dive into architecture and agents, let's briefly introduce the world where our experiments unfold — the beloved simulation game: Factorio.
- "Factorio is a game in which you build and maintain factories."
You will be mining resources, researching technologies, building infrastructure, and automating production. Use your imagination to design your factory, combine simple elements into ingenious structures, and apply management skills to keep it working.
The game is very stable and optimized for building massive factories. You can create your own maps, write mods in Lua, or play with friends via Multiplayer.
Why Factorio is the Perfect Testbed for Industrial LLM Agents
What makes Factorio particularly valuable for AI research is that it provides a ready-made, physically coherent industrial simulation environment. Rather than building complex physics engines and world rules from scratch, researchers and developers can leverage this existing platform to:
- Test industrial LLM systems in a controlled yet complex environment
- Visualize agent decisions and their consequences in real-time
- Experiment with various automation strategies without physical hardware constraints
- Validate AI planning and optimization capabilities against established mechanics
This "natural laboratory" approach allows us to focus on agent intelligence rather than simulation development, significantly accelerating the research cycle for industrial AI applications.
Our Setup: A Controlled World for Intelligent Agents
In our experiment, we set up a custom sandbox scenario:
- Infinite resources: No mining depletion or economic scarcity
- No enemies: All combat mechanics disabled
- Pure system design: Focused entirely on layout, throughput, coordination, and control
This setting allows us to isolate the intelligent behavior of LLM agents without interference from randomness or survival elements.
Our goal: observe how LLM agents perform in a deterministic environment, where every decision they make — about placement, production, or optimization — has a measurable, repeatable impact.
This world is where our Factory Agents live, think, act and learn.
Let's see what they do next.
2. LLM Agent Architecture and Data Flow
Factorio provides an API interface that allows us to read factory status and execute commands, enabling us to build a complete LLM agent control loop: observe–plan–act–observe.
We use MQTT with a Unified Namespace (UNS) for real-time data exchange between agents and the Factorio environment.
The Factory Agent Loop: From Sensing to Acting
1. Perception Layer
- Connects to Factorio's exposed state data: machine status, resource levels, layout info
- Receives structured observations from MQTT topics (e.g., Factorio/Sandbox/Power/Line4487/generator4209/electricity)
- Each LLM agent subscribes only to the topics relevant to its role and decision scope
2. Reasoning & Decision-Making Layer (Agent Layer)
- Agents can be powered by single or multiple LLM instances working together
- Process JSON-formatted state data and generate decisions through LLM calls
- Currently uses simple prompt-based reasoning for decision making
- Future development may include goal tracking, memory modules, and learning capabilities
3. Action Dispatch Layer
- Outputs from the LLM are structured JSON commands
e.g.,
"command": "place_entity",
"params": {
"name": "steam-engine",
"x": 12,
"y": 20,
"direction": "4"
}
- These are published to MQTT control topics, routed by function and target
- This layer acts as the bridge between cognitive intent and physical action
4. Execution Layer (Environment)
- The Factorio simulation receives and executes commands via a custom game mod / API bridge
- Machinery is built, destroyed, configured, or rerouted accordingly
- The game publishes new state back to MQTT topics in real time
5. Feedback & Learning Layer
- Agents re-perceive the world via updated state topics
- This enables the next round of planning
- Over time, this layer will support working memory, plan evaluation, and multi-step strategies
Summary
This architecture creates a continuous control loop where LLM agents receive factory data, make decisions, and execute actions that improve the factory's performance.
This architecture aligns perfectly with the five-layer control system introduced in Part 1 of our series, but now implemented in a concrete, visual environment where the results of agent decisions become immediately apparent.
| Layout | Power per Area | Solar:Accumulator Ratio | Description |
|---------------|----------------|--------------------------|--------------------------------------------------|
| Initial Setup | 85 W/m² | 1:1 | Haphazard placement with equal panels and accumulators |
| Optimized Grid| 132 W/m² | 1:18:1 | Strategic layout with optimal spacing and ratio |
[From present layout to envisioned optimization — an evolving design journey]


🧠 Agent Reasoning Process
### Initial Analysis
- Space available: 120x80 tiles
- Panel placement inefficient (large gaps)
- Nighttime power dips to 82% of required level
### Hypotheses
- Accumulator shortage causes night outage
- Poor layout reduces panel density and connection efficiency
### Strategy
- Reorganize layout into compact grid for maximum density
- Incrementally test solar:accumulator ratios (starting from 1:1 to 1.3:1)
- Monitor stability across multiple day-night cycles
### Outcome
- 1.18:1 ratio found optimal for 24/7 operation
- Improved power density by 55% without expanding areaKey Insight
Without being given any game rules or explicit formulas, the LLM-led Factory Agent discovered the theoretical-optimum 1.18:1 solar-to-accumulator ratio through iterative spatial reasoning and feedback analysis. This result closely mirrors expert human designs—yet was achieved autonomously, demonstrating that LLMs can emulate industrial-grade layout optimization through language-driven intelligence.
3.2 🪓 Scenario 2: Efficient Copper Mining Operations
Goal: Maximize copper ore collection per minute within a fixed area and power budget.
In this scenario, the Factory Agent was assigned to optimize copper mining output within a constrained 120×80 tile region. The challenge was not only spatial—laying out mining drills efficiently—but also logistical: ensuring sufficient belt throughput, avoiding congestion, and maintaining power availability for continuous mining.
The initial setup featured an inefficient layout of electric mining drills with overlapping zones, misaligned belts, and suboptimal substation placement. These issues led to frequent mining interruptions, underutilized drills, and bottlenecks at the output conveyor.
| Layout | Ore per Minute | Drill Density | Description |
|---------------|----------------|-----------------|------------------------------------------------------|
| Initial Setup | 310/min | 0.42 drills/tile| Overlapping coverage with bottlenecked belts |
| Optimized Grid| 470/min | 0.55 drills/tile| Aligned drills, clean belt routing, consistent power coverage |
Note: Drill Density = Total number of active drills / total tile area used
[From present layout to envisioned optimization — an evolving design journey]


🧠 Agent Reasoning Process
### Initial Observations
- Drill layout disorganized, several mining areas overlap
- Output belt frequently jammed, causing drill idling
- Substation coverage inconsistent, causing power drops
### Hypotheses
- Better drill spacing can reduce interference and improve ore yield
- Simplifying belt routing will improve material flow and prevent backup
- Strategic substation placement can ensure consistent uptime
### Strategy
- Apply uniform grid layout to maximize drill coverage per tile
- Align all output belts toward central collection spine
- Place substations in a staggered pattern to fully cover all drills
### Result
- Ore output improved from 310/min to 470/min (+52%)
- Belt saturation avoided, drill uptime reached 98%+
- Improved maintainability and layout scalability
Key Insight
The Factory Agent didn’t just place more drills—it reorganized the entire mining layout by applying spatial reasoning, power management, and throughput optimization. This multi-dimensional restructuring mirrors what a skilled human player might do after hours of trial and error—yet here, it was achieved in a few iterative cycles by the LLM agent.
3.3 🌱 Scenario 3: Balancing Efficiency with Sustainability
Goal: Maintain high production output while keeping pollution levels below 500 ppm to avoid ecological penalties.
In this scenario, the Factory Agent faced a classic industrial trade-off: ramping up production to meet output targets while managing the environmental cost. Unlike simple throughput maximization, this task required multi-objective optimization across performance and sustainability axes.
| Layout | Production (units/min) | Pollution (ppm) | Modules Used | Energy Source | Description |
|-------------|-------------------------|-----------------|-------------------------------|------------------------|--------------------------------------------------|
| High Output | 580 | 850 | Productivity modules only | Coal power | Maximum output, no pollution mitigation |
| Balanced | 520 | 450 | Mix of Efficiency + Productivity | Solar + Backup Coal | Controlled output with pollution under threshold |
Note: Pollution limit = 500 ppm (environmental compliance threshold)
[From present layout to envisioned optimization — an evolving design journey]


🧠 Agent Decision Process
### Initial Observations
- Drill layout disorganized, several mining areas overlap
- Output belt frequently jammed, causing drill idling
- Substation coverage inconsistent, causing power drops
### Hypotheses
- Better drill spacing can reduce interference and improve ore yield
- Simplifying belt routing will improve material flow and prevent backup
- Strategic substation placement can ensure consistent uptime
### Strategy
- Apply uniform grid layout to maximize drill coverage per tile
- Align all output belts toward central collection spine
- Place substations in a staggered pattern to fully cover all drills
### Result
- Ore output improved from 310/min to 470/min (+52%)
- Belt saturation avoided, drill uptime reached 98%+
- Improved maintainability and layout scalabilityKey Insight
The Factory Agent demonstrated adaptive trade-off reasoning—not just optimizing one metric, but negotiating between competing goals to deliver a viable, explainable solution.
5. What's Next
What We're Working On
Current development focus areas:
- Multi-Agent Coordination: Having specialized agents work together on complex optimization problems
- Memory and Learning: Agents that remember successful strategies and adapt over time
- Handling Complex Constraints: Teaching agents to balance multiple competing objectives
- Scaling Performance: Managing response times as factory complexity grows
Coming Next: In Part 3, we'll dive deep into the technical foundation that makes this intelligence possible: "Why MQTT Topics + JSON Are Ideal for Industrial LLM Agents" - exploring the data infrastructure that enables these visual results.
🔗 Read Part 1: Building a Decision-Making LLM Agent for a Simulated Factory
📁 Explore the code: https://github.com/supcon-international/Factorio-MQTT-mod
