Live data from Hacker News

B-trees in Factorio

razberry.substack.com

21–30 of 65 posts

Re: B-trees in Factorio

#21

An inefficient design, but computer-science theory in Factorio means playing suboptimally necessarily. (Factorio wasn't designed to show off B-Trees, all the tools were designed to ya know... play Factorio) ------------ 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'd like to talk about. 1. Self-balancing trees (2-3 trees, Red-black Tr…

Is there a Factorio extension like "Scriptorio" that lets you put JSON on conveyor belts? With JavaScript or Lua function factories. Then you could pass the b-trees themselves around with conveyor belts and inserters, as well as the objects to insert and search. And write a recursive search function with a loop of conveyor belts running through factories, that just loops the tree around peeling off a level at a time…

Factorio is extremely mod friendly

If it doesn't exist you can probably wedge it in fairly easily.

I suggest that it would be worth your time to give it a poke just to see what a thoroughly excellent example of software engineering they've made there.

Re: B-trees in Factorio

#22

Earlier quoted context omitted.

Is there a Factorio extension like "Scriptorio" that lets you put JSON on conveyor belts? With JavaScript or Lua function factories. Then you could pass the b-trees themselves around with conveyor belts and inserters, as well as the objects to insert and search. And write a recursive search function with a loop of conveyor belts running through factories, that just loops the tree around peeling off a level at a time…

Factorio is extremely mod friendly If it doesn't exist you can probably wedge it in fairly easily. I suggest that it would be worth your time to give it a poke just to see what a thoroughly excellent example of software engineering they've made there.

Oh I know, but normal Factorio is Programmer Crack, and going meta like that would be like Scarfacing Programmer Fentanyl for me!

First I'd use it to implement an email reader, and then ... more Factorio mods!

Then Terraform integration.

https://en.wikipedia.org/wiki/Jamie_Zawinski#Zawinski's_Law

Re: B-trees in Factorio

#23

Earlier quoted context omitted.

> I haven't played Factorio in years Oh geez, your comment reminds me of like 8 years ago. You've really been out of the loop haven't ya? Yeah, what you say used to be true, but that's not what I'm talking about. All splitters today can split items off. You can just click on a modern splitter and say "Left side Iron ore", and all iron-ore leaves the left side of the splitter, and all other items go out the right side…

Who said anything about throughput ? Splitters can still only filter out a single item type, so if your goal is to do comparisons using a single entity (for clarity reasons for instance), they won't cut it. ---- Also, Factorio speedrunning has no metagame, since it's not a PvP game (well, aside from the less played PvP mode) : speedrunners don't have to adapt to changes in tactics of other speedrunners, they only hav…

[deleted]

Re: B-trees in Factorio

#24

Earlier quoted context omitted.

> I haven't played Factorio in years Oh geez, your comment reminds me of like 8 years ago. You've really been out of the loop haven't ya? Yeah, what you say used to be true, but that's not what I'm talking about. All splitters today can split items off. You can just click on a modern splitter and say "Left side Iron ore", and all iron-ore leaves the left side of the splitter, and all other items go out the right side…

Who said anything about throughput ? Splitters can still only filter out a single item type, so if your goal is to do comparisons using a single entity (for clarity reasons for instance), they won't cut it. ---- Also, Factorio speedrunning has no metagame, since it's not a PvP game (well, aside from the less played PvP mode) : speedrunners don't have to adapt to changes in tactics of other speedrunners, they only hav…

Meta doesn't mean metagame.

"The Meta" is how most other people play. The "standard" set of designs that experienced players have all discovered (and rediscovered) as you play the game. Ya know, 3-wire assembly machines feed into 2-green circuits kinda things.

There's patterns of play between players. We all got our own style, but some designs are universally deployed across all experienced players, because those designs are just so good.

Re: B-trees in Factorio

#25

Earlier quoted context omitted.

Factorio is extremely mod friendly If it doesn't exist you can probably wedge it in fairly easily. I suggest that it would be worth your time to give it a poke just to see what a thoroughly excellent example of software engineering they've made there.

Oh I know, but normal Factorio is Programmer Crack, and going meta like that would be like Scarfacing Programmer Fentanyl for me! First I'd use it to implement an email reader, and then ... more Factorio mods! Then Terraform integration. https://en.wikipedia.org/wiki/Jamie_Zawinski#Zawinski's_Law

steam tells me my play time is 2,779.2 hr

i got bored / sane after the first 10k SPM base, ~1,200hr. then i got into making "me" mods.

Re: B-trees in Factorio

#26

An inefficient design, but computer-science theory in Factorio means playing suboptimally necessarily. (Factorio wasn't designed to show off B-Trees, all the tools were designed to ya know... play Factorio) ------------ 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'd like to talk about. 1. Self-balancing trees (2-3 trees, Red-black Tr…

Superficially examining the Clos Network article, if Factorio is amenable to creating such networks, then it seems like it would be possible to create some of the simpler neural network designs, such as shown here: [1] Maybe having something like a weighting of the resource density arriving at a certain location to change the output? From the mechanics I can see here [2] it looks like Mergers / Un-Mergers and three belt speeds could probably do density weighted decision making.

[1] https://www.asimovinstitute.org/wp-content/uploads/2019/04/N...

[2] https://wiki.factorio.com/Belt_transport_system#Splitters

Re: B-trees in Factorio

#27

Earlier quoted context omitted.

thanks for the notes! def want to see if I can implement self-balancing next - was thinking the bots would come in handy here? not sure if its possible to have them dynamically build blueprints

The main issue with bots is that they "cheat" what you're trying to do and just instantly solve the problem. You can click on your logistic auto-fetch feature and just have robots search all the boxes for the items you want, and they'll automatically refill your inventory to 300-belts. And then when you build a belt somewhere, you can either choose from your inventory, or shift-click and/or blueprint build to have ro…

And a good reason to be pick about bots is in the endgame the limit is ones hardware, and bots are really computationally demanding compared to other transportation

Re: B-trees in Factorio

#28
> BSTs however are not good for disk based storage.

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're using C, you're probably not implementing your own tree-based map.

You can then use different variants such as packing more entries into interior nodes by only storing values in the leafs (assuming you're making a map and not just a set, that is). If you then link neighboring nodes, you basically have a skip list.

Re: B-trees in Factorio

#29
post #28

> BSTs however are not good for disk based storage. 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're using C, you're probably not implementing your own tree-based map. You can then use different variants such as packin…

For further reading on this, see for example:

[0] https://abseil.io/blog/20190812-btree

[1] https://opensource.googleblog.com/2013/01/c-containers-that-...

Re: B-trees in Factorio

#30

An inefficient design, but computer-science theory in Factorio means playing suboptimally necessarily. (Factorio wasn't designed to show off B-Trees, all the tools were designed to ya know... play Factorio) ------------ 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'd like to talk about. 1. Self-balancing trees (2-3 trees, Red-black Tr…

thanks for the notes! def want to see if I can implement self-balancing next - was thinking the bots would come in handy here? not sure if its possible to have them dynamically build blueprints

> not sure if its possible to have them dynamically build blueprints

Not in the base game, but there's a mod for it. Nilaus recently did a short series of videos on YouTube where he used it to make an auto-expanding factory, so you should be able to find the mod name there if you want to mess with it.

Post reply on HN