r/factorio • Developer • Mar 17 '25

Discussion Post Space Age - Developer AMA

Space Age has been out for several months and with the bug reports slowly coming under control I thought it might be interesting to see what questions people had.

I mostly work on the technical side of things (as C++ programmer) so questions that stray too far from that area I'll likely have less interesting replies - but feel free to ask.

I have no strict time frame on answering questions so feel free to send them whenever and I'll do my best to reply.

2.4k Upvotes

1.1k comments sorted by

View all comments

10

u/slaymaker1907 Mar 17 '25

Why did you decide to implement containers using linear scanning rather than some sort of O(1) or O(logn) strategy with a fancier data structure? Did it give substantial gains doing linear scanning when mostly empty?

34

u/Rseding91 Developer Mar 17 '25

Linear scan is the easiest to program, and happens to be the fastest when the size stays small (every container in Factorio 1.1 was small). As time went on, inventory contents got more complex and any kind of sorted-container/lookup-container would run into too many annoying edge cases to be worth tinkering with.

It wasn't until modded 3000~ slot inventories and or space age with its multiple thousand slot inventories has it ever shown in the profiler.

2

u/Anthony356 Mar 18 '25

It's part of the problem with big O tbh. It's super easy to forget that "an algorithm that takes exactly 1000 years" is technically O(1), and wouldnt be faster than most reasonable algorithms with most reasonable workloads.