💾 Archived View for dioskouroi.xyz › thread › 24940316 captured on 2020-10-31 at 01:01:04. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
________________________________________________________________________________
The Factorio developers have spent a very impressive amount of effort optimizing the game. Here's a few more Friday Facts about how they optimized specific aspects of the game:
- Friday Facts #82 - Optimisations:
https://www.factorio.com/blog/post/fff-82
- Friday Facts #117 - Path Finder Optimisation I:
https://www.factorio.com/blog/post/fff-117
- Friday Facts #176 - Belts optimization for 0.15:
https://www.factorio.com/blog/post/fff-176
- Friday Facts #204 - Another day, another optimisation:
https://www.factorio.com/blog/post/fff-204
- Friday Facts #209 - Optimisation is a way of life:
https://factorio.com/blog/post/fff-209
- Friday Facts #281 - For a Few Frames More:
https://factorio.com/blog/post/fff-281
https://www.reddit.com/r/factorio/comments/jizq1b/i_programm...
Interesting 4 month project. You can tell a ton of programmers play Factorio from that thread alone.
Holy crap !
Peter Molyneux, designer of Black and White (an old god-game) said that he wanted to make a game that he could look over someone's shoulder playing it, and know them better than if he'd spent an hour talking.
Few games give you enough creative choice to materialise how your head works in a game. A lot either over-prescribe the optimal way of doing it, or the meta just forces your hand.
Factorio lets you use rules to express yourself within a space they made for us. I play it for the same reason I first coding.
> I play it for the same reason I first coding.
I'll go on a bit of a tangent and say that I don't play Factorio for the same reason that I keep coding.
The gameplay gives you creative choices and sets of rules, and a satisfaction of working within those rules to get things going by reflecting your head inside it, much like programming.
I bounced off of it after a few short hours, with a deep sense of lost time. If what I do in the game is the same I would do for work or as side projects, then why am I choosing the game, which has no outcome in the real world?
I went back to my side project, and never played Factorio again.
I read on HN a month or two ago that burnout is associated with repeat large scale failures, and the way to recover from burnout is to have repeat small scale success.
Games, such as factorio, can provide you with the small scale successes relatively risk free, allowing you to recover from burnout.
If you consider this from the functional perspective, then it becomes yet another useful tool to the developer.
"Games, such as factorio, can provide you with the small scale successes relatively risk free, allowing you to recover from burnout"
True. But they can also provide you with cheap instant "successes" which a depressed person continues to go for, instead of seeking success in the real world.
More often than not, success in the real world is about keeping focus and avoiding burn out.
The difference is that factorio is artificial, so it can cultivate that flow feeling perfectly. If that’s what you seek, then factorio will give it to you.
A side project may well give you that some of the time, but will also involve tasks that don’t give you that.
In other words, factorio is a game! They rigorously exclude more realistic features if they believe they'll make the game less fun. You can't do that in real life! When I play it, I feel like I'm working on a side project in that peak phase where you're fleshing it out and what you have in your brain is appearing in front of you. As another commenter said, it helps you recover from the constant stumbling blocks and blockers that burn you out during real development.
When I had a job change last winter that had me not programming (I build automation solutions around business processes) for about 4 months, I was rather frustrated with the constant planning and strategy meetings. I tried to get into a side programing project, but couldn't really settle into one. That's when I saw/remembered Factorio and started on it. It scratched that itch and I spent hours playing the game.
Once my job got back into more hands-on programming, I quickly lost interest in playing Factorio. I've been reading other programmers having the same feeling. You expend the same type of mental processing with both, so one makes you too tired to do the other.
That said, if I have a long weekend or a week off, I might find some time and enjoy playing it, and still feel refreshed when returning to work.
This is exactly why I can't enjoy "puzzle games" like The Witness, Antichamber, or even Sudoku, et al. Why would I want to solve puzzles with known answers that thousands of people have already solved? The puzzles may look cool or have interesting mechanics, but the answers are already set in stone. Nothing novel or emergent can happen. I already solve problems all day long for work. I don't want to solve arbitrary ones in my free time. Just my personal mindset. I do enjoy most other types of games.
> Why would I want to solve puzzles with known answers that thousands of people have already solved?
For the same reasons you might engage in any entertainment activity.
Real-life still-unsolved puzzles are hard ; whereas puzzle games keep the difficulty under some control (except for the infamous boat puzzle in The Witness).
Real-life problems are hard because, often, proper domain modeling/formalization is part of the problem. Puzzle games generally don't have this 'domain modeling' part, they provide you with an extremely consistent set of rules, and you have to build a solution inside it. Sometimes this set of rules is partly implicit, and discovering it is part of the fun (e.g The Witness, Antichamber) ; but you never have to worry about the real-world and it's complexity.
When I played Baba is You, solving a puzzle didn't feel like fixing a problem. It felt more like the instant you finally get a joke, or come up with a good punchline yourself. The mechanics of the puzzle game combine in surprising and entertaining ways, and the puzzle designer sets up the situation to force you to experience the same thing they felt when they found that combination.
Not every puzzle game has mechanics that combine in such surprising and entertaining ways so consistently, but I think this feeling is what most of them are going for.
This is the reason I almost can't enjoy _any_ single player, story-driven game or puzzle game. These days I only play multiplayer, online games because even if we're all playing the same game, every experience and interaction is something new. People are unpredictable and they keep things interesting.
The one type of single player game I do play are either city building games or 4X games. The freedom for creativity and randomness, respectively, makes every game new.
Do you watch movies, TV shows or read books? Playing a single player story game is the same as those other art forms for me.
I had a similar experience, I loved it, I had a great 20 odd hours several years ago, but experienced the realisation that the greater ‘game’ out there was a better use time and have not gone back (compared to civ or stellaris, or prison architect, which I give 10 hours to a couple times a year)
The game is great, I just can’t spend that much time... psychologically... repeating the same motion ad infinitum
I feel like the game cultivates all sorts of wisdom regarding supply-chain logistics, monitoring, project management, task prioritization, queueing theory, and just general engineering problem-solving.
It’s like how budding Chinese military leaders were once (still?) encouraged to play Go. It shapes your mind and develops patterns that will later prove applicable to real-world situations.
Same story with SpaceChem for me. I played it for the first time a couple of months ago. Played for an hour. Spent most of the time optimising, beat all my friends' scores, quit and vowed never to touch it again.
That's why I stopped playing Dota. I don't to be a middle school teacher. If I'd want that I'd focus more on going into management and get better pay along the way.
> _a game that he could look over someone's shoulder playing it, and know them better than if he'd spent an hour talking._
If I think back at how my various friends played The Sims back in the day, I think that's a pretty high contender of meeting that goal.
I think Minecraft is a great example of this. There is such a wide variety of ways to derive intrinsic or extrinsic rewards from the game that it encourages a wide variety of play styles tuned to each player's psychology.
Watch my oldest daughter play, and you'd think Minecraft was purely an RPG about slaying as many bag guys as possible.
Watch my youngest, and you'd think it was an adorable farm animal simulation.
Watch me, and you'd think it was a low-res architectural sandbox.
> Peter Molyneux, designer of Black and White (an old god-game)
Wow, I didn't thought he will be know for that particular game, for me he is the creator of Populous and Powermonger :)
Although I played Black and White for much longer then any other of his games (but I didn't remember he made B&W, but I do remember Populous :)
The Witness also does this for me. At least as far as like the scientific method and problem solving are concerned.
"less flawless than intended" is a good way to think about it. Factorio is a good game, but what makes it great is just how flawless it is. You can grow your factory for hundreds of hours before you run into any performance limitations, and it will never ever crash or glitch or desync. They've spent years making it as flawless as possible.
I think this is party true due to how well their test setup is. Being able to automated regression test every feature of the game[0]. Having a comprehensive test suite also helps you as a developer to dive into the code and refactor away with confidence that you don't break functionality. Thus allowing for more aggressive and efficient refactoring and experimentation. At the end, it's not the code that is your application, its the features. Code can flow into many different ways from these features.
[0]
https://www.youtube.com/watch?v=ivLFP2eApto
That's really impressive. I'm not into the game industry at all but I get the impression that automated testing isn't so much of a thing with a lot of games, and they depend on manual testing a lot, either with armies of game testers or a community (for early access games), especially for games with a lot of randomness and "emergent" behaviour.
But for an indie game like Factorio with so much development, features, interactions, etc it's almost mandatory.
I'm sure most games have a big automated testing suite though, there's too much in there nowadays to warrant manual testing.
Given how weak some AAA titles are regarding bugs (Bethesda, Horizon Zero Dawn) I highly doubt there is _any_ automatic testing being done in most AAA games, let alone indies.
Guerrilla games actually does some extensive testing on their game[0]. Like AI bots playing the game continuously to uncover bugs.
But they are a Sony first party game studio which means they have a lot of experience to gain regarding the PC platform which is more diverse than a console and requires an even more extensive testing setups.
Also, a lot of these kind of games are also highly driven by art style. Which is really hard to capture in automated test suites. Add to that the complexity of a 3D world and all its interactions and associated math.
[0]
https://www.youtube.com/watch?v=2VDlX3Dqm0w
They released a game for 50€ that regularly crashes. That is not something a good studio does. Sure, they don't have experience with the PC, but that doesn't excuse the buggy release, and I'll dare call their testing for PC garbage if it let those kinds of bugs through.
>Also, a lot of these kind of games are also highly driven by art style. Which is really hard to capture in automated test suites. Add to that the complexity of a 3D world and all its interactions and associated math.
To be honest I wouldn't know where to start testing the art stuff, but the crashes should be doable automatically relatively easily.
For Horizon Zero Dawn, are you talking about the PC version? Because I didn't encounter any glaring or obvious (certainly nothing game breaking) bugs when I played the PS4 version. I don't actually remember encountering any, but I'm sure there were some minor ones that I forgot about. I certainly wouldn't give the PS4 version as an example of how weak AAA titles are regarding bugs.
Yes, I meant the PC version. I don't have experience with the PS one.
A newer video of the tests (2019 vs 2014), in parallel:
https://www.youtube.com/watch?v=LXnyTZBmfXM
Absolutely. There's no way anybody could hand-test all of Factorio. Certainly you could play it and find bugs, but to deliberately test every single feature on any kind of regular schedule would be incredibly tedious and error prone.
An insane bit is that it's a custom game-engine, written in C++, and yet it runs on Mac, Windows and Linux. That better cross-compatibility than most Unity games written in C#!
I thought it used Alegro? Did they change that?
They used Alegro until a couple years ago, when they did a complete graphical rework of their interfaces & at the same time wrote their own GUI code to replace what Alegro was being used for.
They replaced it with a custom renderer:
https://www.factorio.com/blog/post/fff-230
I would say that this game is a Software Engineering marvel.
I hope they make the source code public one day.
Hear hear! Factorio is exceptional - if it was more accessible it would be held up as the greatest game ever. But then, if it was more accessible, it wouldn't be the greatest game ever... scream!
I was wondering, what's the "right" way to run a Factorio-like simulation, algorithmic ally speaking? I.e. You have conveyor belts bringing items to/from producer/consumer objects. A conveyor can only move its item forward if the next conveyor tile is empty (or is moving its current item off). Can you do this in a single pass over conveyor tiles and/or items?
It feels like there should be an elegant solution.
Not quite what you were asking for, but Factorio updates only segnebts of belts (made of multiple tiles) wuthout touching the items:
https://www.factorio.com/blog/post/fff-176
The general way you design simulation is that you have a master list of entities (each inserter, conveyor belt, etc. is a different entity), and each type of entity has its own doTick code that updates each tick. Then the very first optimization you implement is realizing that most entities don't do anything most of the time, so you segregate the list into active and inactive entities and only process active entities each tick.
Right, but what's in the doTick of a conveyor belt cell? Presumably it would look something like:
if nextCell.isEmpty(): moveContentsToNextCell()
But what happens when you have A connected to B connected to C and A and B have items? It depends upon the execution order of A and B's doTicks(). If A's runs first then B is still full and so A can't advance its contents. If B's runs first, then it passes its contents to C and then can receive from A when A runs.
You might put the entities into a graph, order them by their connections and run the doTicks in the right order. But you can't do that if there are loops in the conveyor belts (which Factorio handles, at least). I haven't come up with a trivial modification of this scheme to handle these problems. Do you have to do multiple passes until everything has gotten a chance? Or maybe a priority queue? I'm not sure. And what if the loop is entirely full? It should advance all the contents one square but may instead get jammed.
There's often a deterministic order of evaluation, to support multiplayer (you want every client to get the same results in all cases).
> And what if the loop is entirely full? It should advance all the contents one square but may instead get jammed.
In Factorio, it jams.
But what deterministic order do you use? Any order seems problematic to me, once loops are involved. Certainly if you just pick a naive order like "lowest entity ID runs first", then you end up with a lot of items not moving when they should, since the cell in front of them is still full even though it'll empty later this tick.
And what would you do if you want the entirely full loop to not jam? It sounds possible, probably even simple, but I haven't seen how. A solution to this problem is orthogonal to the points you've raised.
> you end up with a lot of items not moving when they should, since the cell in front of them is still full even though it'll empty later this tick.
That's actually not as big a problem as you'd expect. You would end up with 1-tick gaps, but at 60 ticks-per-second, those kinds of gaps don't end up being an issue, especially when you've got a backed-up buffer that has some natural hysteresis waiting to fill that gap.
> And what would you do if you want the entirely full loop to not jam? It sounds possible, probably even simple, but I haven't seen how.
Compute the graph of connectivity at entity construction, precompute a topological iteration order, and handle each strongly-connected component as an individual entity. Or maybe you could do it with merely a list of elementary cycles; it would take some work to figure out what you want the semantics of loop motion to be if a belt is in multiple loops.
I suspect the answer can be found in how more general physics engines work.
https://en.wikipedia.org/wiki/Physics_engine
I'm imagining a discrete system here, like a tile-based map. I haven't actually played Factorio, so I'm just assuming that's how it works (seems like it from the link a sibling post gave). As such, I'm not sure physics engine share much in common here.
It's not as simple as a tile-based map. Structures are built on a square tile grid, but objects on belts move at a much finer resolution, and have a bunch of specific behaviors (moving in two lanes, being picked up or dropped onto belts by inserters, belts merging into other belts, etc).
Older versions of the game actually used an even more flexible physics engine for objects on belt (not restricted to two lanes), but that was deemed unnecessarily complex -- and the current model is much more performant.
The powerline fix (dragging and it not placing the last pole) is awesome, it's a bug that always bothered me even though I understood exactly what "edge case" (not that "edge" but still) it was hitting. Also wires in blueprints/ghosts is nice. I'll have to play with the ghost fast replace but I think this will be very nice once I re-train myself to trust the expected way you want that to work (vs knowing it doesn't work normally and adjusting for it).
Overall I continue to be impressed by the Factorio team and consider it some of the best money I've ever spent on a video game. In terms of return on investment (time-wise) I think it's got every game beat expect maybe Skyrim for me. (especially if you exclude my video game time from before I went to college and cut back drastically)
I got really in to Factorio for a while. Then I beat it (Launched the rocket in to space), and ever since then I have no desire to go back. I think it just feels too much like work for me now. I think the fact that Factorio feels so much like programming both makes the game great, and makes the game exhausting. Nowadays, after a full day programming, I just want to relax with games that don't require refactoring.
That being said, it's a great game and would still recommend it to anyone that hasn't played through it.
If you want to add some replayability, I'd suggest you try Bob's mods. Other than that, I share the same feeling, low replayability contrasted by its high playability.
Space Exploration mod adds a wonderful "new game plus" type experience: launching the rocket is just the first step towards building a galactic empire. You actually ride the rocket up into orbit and there are many new space-only buildings and sciences.
It's amazing how powerful the mod system is. FNEI is a great in-game directory of resources/recipes that I'd recommend with any new mods you're trying. SpaceEx add a whole new 'navigation satellite' mode that lets your remotely configure buildings and an interface for selecting planets and stars (in addition to the standard new buildings/recipes/vehicles of most mods).
Factorissimo (building that can be entered and contain more land than their footprint) and Recursive blueprints (automated blueprint usage) also add tons of potential depth.
Factorio is awesome, but I found that I needed to enable infinite ores/oil and disable evolution to really enjoy it given my time constraints. Adding the nesting factories mod (can't recall the name) was also a QoL improvement for me.
If you find the regular game tough to get into, try playing with some basic mods.
> Adding the nesting factories mod (can't recall the name)
Factorissimo or Factorissimo2
Damn, if only I still had time for Factorio... TT
You need to ask yourself a question: how much sleep do you really need :)