TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

B-trees in Factorio

330 pointsby hellorashidover 1 year ago

9 comments

dragontamerover 1 year ago
An inefficient design, but computer-science theory in Factorio means playing suboptimally necessarily. (Factorio wasn&#x27;t designed to show off B-Trees, all the tools were designed to ya know... play Factorio)<p>------------<p>So I have to comments. #1 is about the Comp-Sci side, and #2 is about the optimization side. #3 combines both together for what I&#x27;d like to talk about.<p>1. Self-balancing trees (2-3 trees, Red-black Trees, and B-Trees) are about the self-balancing part. Not just the construction of a singular tree. You cannot recongfigure trees to rebuild themselves in Factorio, so the biggest feature is missing already.<p>2. From an optimization perspective: inserters are slower than belts. Even 4 inserters per belt only allows like 12-items per second, and blue-belts can push 45 items-per-second. You want to use splitters (which operate at full speed: 45 items per second) for the best belt-only design. (Bots obviously sort items fastest, but I am presuming this is some kind of belt-only challenge build).<p>3. The intersection of splitters + computer science is therefore: the Splitter (Factorio) and Benes Networks (creation of networks built off of only a 2-input to 2-output crossbar). If you really want to have a crazy good factory design, start studying this stuff: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Clos_network" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Clos_network</a> (A Benes network is simply a Clos network of size 2-input and 2-outputs. Clos networks are of any size: like 5-to-7 and other such odd numbers)<p>--------<p>In Factorio, the meta you want to be searching for is &quot;mixed belt&quot; design, it seems.
评论 #38283854 未加载
评论 #38281952 未加载
评论 #38282438 未加载
评论 #38281328 未加载
评论 #38289606 未加载
评论 #38281261 未加载
评论 #38288259 未加载
评论 #38281390 未加载
eatonphilover 1 year ago
Awesome to see this.<p>&gt; i&#x27;ve been reading Database Internals with a book club, and this week was chapter 2, about B-Trees.<p>For the crowd: signups are closed. But if you want: grab a copy of Database Internals and follow along &quot;read-only&quot; with the schedule and notes here: <a href="https:&#x2F;&#x2F;eatonphil.com&#x2F;2023-database-internals.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;eatonphil.com&#x2F;2023-database-internals.html</a>.
skitterover 1 year ago
&gt; BSTs however are not good for disk based storage.<p>The listed reasons also apply to in-memory storage – searching a btree node is faster than doing the equivalent amount of pointer traversals for a binary tree. Of course this comes at the cost of increased implementation complexity, but unless you&#x27;re using C, you&#x27;re probably not implementing your own tree-based map.<p>You can then use different variants such as packing more entries into interior nodes by only storing values in the leafs (assuming you&#x27;re making a map and not just a set, that is). If you then link neighboring nodes, you basically have a skip list.
评论 #38282786 未加载
jon-woodover 1 year ago
Why did someone have to go and post Factorio content here? Now I’ve got the urge to sink another hundred hours or so into it when there are already way too many good games to play this year.
评论 #38299549 未加载
pramover 1 year ago
You could do this all with splitters, don’t need the boxes and filter inserters. Nice explanation!
评论 #38280875 未加载
评论 #38281178 未加载
评论 #38281361 未加载
charlieyu1over 1 year ago
How good is Factorio? Everyone says many good things about it, but I’m worried if the game would be too repetitive, and the theme of building factories sounds a bit dull
评论 #38301986 未加载
评论 #38301862 未加载
jakey_bakeyover 1 year ago
This is really cool, but one budding writer to another; it&#x27;s very distracting that capital letters aren&#x27;t used at the start of sentences.
ivanjermakovover 1 year ago
I thought author will implement it with Factorio&#x27;s circuitry..
kunalguptaover 1 year ago
lol nice