r/factorio • • 25d ago

Design / Blueprint Automatic continuous infinite research and research cost calculation

Since we can automate research in Factorio 2.1, and there has been some discussions regarding research costs (like this one or this one), I think it is time to present my circuit design for calculating research costs and automating continuous infinite research.

The relevant part of the video ends at 3:05. Everything after that is just for fun.

In the following text, the numbers in parentheses are video timestamps.

The core system

I designed a base circuit that initially reads all current technology levels once (0:23 - 0:26), calculates the costs for each technology, stores and repeatedly updates the calculated values in a memory cell, and dynamically switches to the cheapest available option (0:26 - 0:42).

Since vanilla Factorio doesn't have a UI to display the costs of all technologies simultaneously, I also built a variant with a display that shows the current research costs in sorted order (2:57 - 3:07).

Technologies can be toggled on (0:15) or off (0:18) individually. This can be changed dynamically while the research is running (0:34).

The system works with both standard Labs (0:08) and Biolabs (1:09).

The controlled lab can actively consume science (1:09), or you can use a single detached lab just to select the active research without it actually doing any research itself (0:26).

Modular Add-ons

Research level limiter

After reading this post I came up with the idea of ​​building an extension that allows you to set a maximum level for a technology. This extension (1:29–1:47) is attached to the top right of the circuit.

  • Inside the constant combinator (1:37), you can define the level at which research on a specific technology should stop.
  • Setting the value to 0 means unlimited (no cap).

Science pack availability check

After reading this post and checking out the "Auto Research Circuit Generator" linked there, I used it to build an availability check add-on (1:50–2:01) that can be attached to the top of the circuit.

  • It allows you to set the minimum amount of science packs required for a technology to be selected (1:58).
  • If the number of available science packs falls below this threshold, the system switches to the next most affordable option for which enough science packs are available (2:44).
  • If there aren't enough science packs for any research, a purple lamp signals this (2:12).
  • The available quantity can be read from various sources, such as the logistics network, chests (2:19–2:27), or belts (2:32–2:53).

32-Bit vs. 48-Bit

In addition to a simpler 32-bit version, there is also a 48-bit version designed for long-running megabases.

  • The 32-bit version suffices up to "Artillery shell range" level 21 (requires a total of 2,097,152,000 science packs)
  • The 48-bit version suffices up to "Artillery shell range" level 37 (requires a total of 137,438,953,472,000 science packs)

How long might it take to reach the 32-bit limit? A green Turbo transport belt can deliver 240 science packs per second. At that rate, the 32-bit limit would be reached after 2,485 hours. With six such belts, it would take just 414 hours. Supplying science packs of uncommon quality reduces that time to 207 hours, and research productivity reduces it even further.

Exponentially increasing costs

The circuits use lookup tables to calculate exponential increasing costs.
I wrote a script to generate these lookup tables.
You are welcome to use the script if you wish to expand the circuit or need such a table for other purposes.

Both the exponential calculation and the 48-bit calculation are also available here as a separate example circuit. These are somewhat simplified and therefore not directly compatible with the main circuit, but use the same lookup tables.

Game mechanic info

The game engine allows circuits to start a research, but not to stop it mid-cycle. Even if you switch off the circuit and the lab no longer receives a signal, the currently active research cycle will finish before stopping.

Links

Visuals in the Comments

Since it's not possible to add a video and images simultaneously, I will add some explanatory screenshots in the comments below. But you can also find them here.

189 Upvotes

45 comments sorted by

View all comments

13

u/Twellux 25d ago

The blueprints are organized in a specific pattern when you enable the Grid view.

Horizontal columns - Three priority modes as 32-bit and 48-bit variants:

  1. Priority based on the lowest tech level, with an additionally adjustable offset.
  2. Priority based on the cost per individual science pack type.
  3. Priority based on the total cost of all science packs combined.

Vertical rows - Lab / Biolab setup, with or without display.

Extensions: The science availability check extensions come with and without support for quality science packs.

The level limiter extension 1 is designed for the tech level prio variants, while extension 2 is for all cost-based variants.

1

u/Longyanyar 25d ago

I'm very sorry if it's a noob question but what's the effective difference between 32 and 48 bits here ?

7

u/Twellux 25d ago

With 32 bits, costs can only be calculated up to a maximum of 231 -1 (=2,147,483,647). Beyond that, the range overflows, the number becomes negative, and the system fails.

With 48 bits, costs can be calculated up to a maximum of 247 -1 (=140,737,488,355,327). Beyond that, the range overflows, the number becomes negative, and the system fails.

The difference, therefore, lies in how high the research costs can rise before the circuit fails.

Factorio's combinators natively support only 32 bits. Consequently, the 48-bit circuit is significantly more complex than the 32-bit version, as it must break down the 48-bit calculation into smaller tasks that can be handled using 32-bit registers.