Top
Best
New

Posted by mariuz 1 day ago

The gold standard of optimization: A look under the hood of RollerCoaster Tycoon(larstofus.com)
536 points | 149 commentspage 2
bluelightning2k 22 hours ago|
Great write up. Thank you. Really great!

I was reminded of the factorio blog. That game's such a huge optimization challenge even by today's standards and I believe works with the design.

One interesting thing I remember is if you have a long conveyor belt of 10,000 copper coils, you can basically simplify it to just be only the entry and exit tile are actually active. All the others don't actually have to move because nothing changes... As long as the belts are fully or uniformly saturated. So you avoid mechanics which would stop that.

plopz 21 hours ago|
I was pretty disappointed with how Factorio reworked how fluids worked in the expansion. The old system had its quirks and the new system is obviously more performant, but it throws realism out the window which is a bummer.
Cpoll 19 hours ago|||
I don't miss it. I also found Satisfactory's old fluid system (with concepts like sloshing) wildly unintuitive. I'll go so far as to say that accurate fluid dynamics is detrimental to any game that's not about beavers and water table management.
rkagerer 15 hours ago||
That's the second time I heard the beaver game come up here... Guess I really ought to try it!
Linosaurus 14 hours ago||
It’s rather neat, and recently hit 1.0.

That game, Timberborn, shares some design elements with roller coaster tycoon.

A block based 3d world they can be modified by the player.

Units walking around on player defined paths, with their mood influenced by pretty bushes.

But there are no obvious performance considerations like in the article.

Starlevel004 20 hours ago|||
The old system was nonfunctional and any base that used lots of fluids (like modded ones, or new space age ones) were constantly running up against nonsensical mechanics.
evandale 19 hours ago||
The pathfinding section reminded me that there's a YouTube steamer, Marcel Vos, who goes into a deep dive of how the pathfinding works.

https://youtu.be/twU1SsFP-bE

He has lots of videos that are deep dives into how RCT works and how things are implemented!

mmcconnell1618 8 hours ago|
I've built a few transportation simulations where I started out with pathfinding methods like A* but the compute cost doesn't scale well with 10,000 or 100,000 agents running around. Pre-computing flow fields for common map destinations is one of those areas where you trade off storage for compute. The agents just look for the signpost telling them "this direction to destination x" instead of actually calculating a path.

https://en.wikipedia.org/wiki/A*_search_algorithm#

https://www.youtube.com/watch?v=zr6ObNVgytk

sroerick 1 day ago||
I had always heard about how RCT was built in Assembly, and thought it was very impressive.

The more I actually started digging into assembly, the more this task seems monumental and impossible.

I didn't know there was a fork and I'm excited to look into it

kevincox 21 hours ago||
Programming in assembly isn't really "hard" it mostly takes lots of discipline. Consistency and patterns are key. The language also provides very little implicit documentation, so always document which arguments are passed how and where, what registers are caller and callee saved. Of course it is also very tedious.

Now writing very optimized assembly is very hard. Because you need to break your consistency and conventions to squeeze out all the possible performance. The larger "kernel" you optimize the more pattern breaking code you need to keep in your head at a time.

mikkupikku 1 day ago|||
Macros. Lots of macros.
cogman10 21 hours ago|||
Yup. I've done a bit of assembly and it's really only a little harder than doing C. You simply have to get familiar with your assembler and the offered macros. Heck, I might even say that it's simpler than basic.
timschmidt 23 hours ago|||
And presumably generous use of code comments
markus_zhang 20 hours ago|||
Back then a lot of people started with assembly because that was the only way to make games quick enough. Throughout the years they accumulated tons of experience and routines and tools.

Not saying that it was not a huge feat, but it’s definitely a lot harder to start from scratch nowadays, even for the same platform.

mrguyorama 5 hours ago||
>I didn't know there was a fork and I'm excited to look into it

OpenRCT2 isn't a fork, it's like OpenTTD, a recreation.

Go look at GDC's Classic Game Postmortems. They have tens of videos of the people who built famous games from the 80s and 90s who often go into technical details of how they do it. For example, Robotron goes into how the code works.

It's remarkably familiar. They basically built object oriented programming and classes using convention only. You treat every actor you want to work with as a chunk of memory with standard layout that includes pointers for behavior and slots for state, and you just try really hard to only operate on the right "Types" at the right places. From there you have your standard game loop of "Get input, update all Actors, render, loop"

The Pitfall postmortem is wonderful. The Atari 2600 had roughly zero RAM to work with, and barely any cartridge space to hold your game. To make their large, somewhat open world, they made each screen built off just a few parameters, and created a bidirectional psuedorandomish function that would generate the parameters on a cycle, giving you a connected map space!

hermitcrab 3 hours ago||
>the game was written in the low-level language Assembly

Surely it wasn't all assembly. There is little to be gained in performance from writing non-bottleneck parts of the code in assembly.

its-summertime 3 hours ago|
> > What language was RollerCoaster Tycoon programmed in?

> It's 99% written in x86 assembler/machine code (yes, really!), with a small amount of C code used to interface to MS Windows and DirectX.

https://www.chrissawyergames.com/faq3.htm

hermitcrab 3 hours ago||
Wow. It reminds me of those guys who run a marathon carrying a fridge. Impressive, but ...
raffraffraff 14 hours ago||
On huge games produced by large game studios, I wonder if the idea of using a real world technical challenge as a "feature" within the game is considered genius? Consider a coder and a game designer who are on different teams and don't attend the same meetings.

But if you look at creative writing, story arcs are all about obstacles. A boring story is made interesting by an obstacle. It is what our protagonist needs to overcome. A one-man-band game dev who simultaneously holds the story and the technical challenge their head, might spot the opportunity to use a glitch or limitation as, I dunno, a mini game that riffs on the glitch.

ionwake 8 hours ago||
also I remember the excitement of a new game that looked different to others.

Somehow even as a child I just knew that it would be a whole new emergent game play experience.

Ofcourse I didnt know waht went into making Rolelrcoaster Tycoon but I could just by a couple of screenshots how this was clearly a ground up new game with new mechanics that would be extremely fun to play.

I dont get this feeling anymore, as I just assyne everything is just a clone of another game in the same engine generally.

Unless its been a decade in production like Breath of the Wild of GTA 5 i just dont expect much.

maxglute 18 hours ago||
Is there a place to find stories of recent game optimization? What's most ridiculous on like quick inverse square route. As someone who spent way too much time vraying in prior life, I still can't believe we got real time ray tracing.
derodero24 7 hours ago||
Biggest lesson from string matching work: layout beats instructions every time. Batch your comparisons into a contiguous buffer so the prefetcher can actually help, and you'll outperform hand-rolled SIMD on random-access data. Compilers handle the arithmetic tricks fine now — they can't fix your cache misses though.
pmg102 12 hours ago||
The article refers several times to the benefits of the game designer and the coder being the same person. I've often felt that this is the only way to build anything impressive, and in fact I'm amazed that corporations with their hierarchical organisation model ever get anything built at all but I suppose you can brute force anything with enough employees.

It does make you wonder if the future of AI-assisted development will look more like the early days of coding, where one single mind can build and deliver a whole piece of software from beginning to end.

makapuf 13 hours ago|
Compilers won't do multiplication by power of two to bit shift for you ? I remember reading in ~2000: the only thing writing a<<2 instead of a/4 will do is make your compiler yawn
zekica 10 hours ago|
Even gcc's -O0 will do the bitshift, but even dividing with 5 on x86_64 will not do idiv:

        imul    rdx, rdx, 1717986919
        shr     rdx, 32
        sar     edx
        sar     eax, 31
        sub     edx, eax
        mov     eax, edx
More comments...