Production Flow in the Game Factorio

Team Members: Nahun Kim


Write-up

1. Description

My project's goal is to build a system that visualize production flow in the game Factorio based on optimal recipes. In the game Factorio, players can craft products by combining multiple materials. For example, copper cables and iron plates can be used to create electronic circuits. The ultimate goal is to build a rocket. Since this process requires a vast amount of materials, players build factories to automate production. One of the biggest challenges in automation is bottlenecks. For example, even if there are enough iron plates, a shortage of copper cables may halt the production of electronic circuits. This visualization not only shows the ratios of machines but also visualizes the flow of machine production, helping in designing factories without bottlenecks.

2. How to use

Select the item you want. You can either find it directly in the dropdown menu or use the buttons for some frequently used items.
Each node is classified by color:
Light green indicates basic resources mined from nature.
Sky blue represents items that require fluid processing.
Green represents items that have an expiration date.
Most other items are gray.
In the visualization, hovering the mouse cursor over each node reveals detailed tooltips and highlights the production flow. If you click on a specific node, you can see its production flow.

3. Differences from A3

I tried to visualize an ideal material ratio in my A3, but this approach had a problem. It is hard to know optimal number of machines that produce optimal ratio of materials. This is because each materials have different production time and production amount.
Instead, I tried to analyze each player’s personal save file, generate a simplified visualization of their production flow, and highlight where bottlenecks are likely to occur. On the other hand, this is very hard to parse save file because it was saved in binary format.
Now I tried to visualize in the form of a Graph (Network), learned in the lecture. This Tree will show the optimal ratio of machines, not materials. It will be more helpful to solve bottlenecks than A3, Because people can easiliy imitate the optimal production flow by placing the same number of machines.

4. Working process

First, I extracted data from the game files. Unlike in A3, this time I need not only the recipes but also detailed information about materials such as production rate and crafting time. I extracted a JSON file containing raw data from the game.
Second, I parsed only the necessary data from the raw data for visualization. I constructed a materials database. Also, I parsed the recipes from the raw data.
Third, Filter recipes. Factorio includes inefficient recipes that are used only in special cases. I manually removed those recipes.
Fourth, I build a graph where resources are nodes and recipes are edges. I tried using D3’s Sankey, Tree, and DAG libraries, but none of them fully met my needs, so I implemented the rendering logic myself.
Finally, I implemented various interaction and visualization techniques we learned in class, such as tooltips that show node data when hovered, switching the production flow of a node when clicked, and coloring nodes differently depending on their category.

4. References

Arrow Marker
copilot - JavaScript/Python Assistant
ChatGPT - translation between English and Korean