Live data from Hacker News

The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

larstofus.com

91–100 of 186 posts

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#91

Warcraft 1 (1994), Warcraft 2 (1995), and StarCraft (1998) all use power-of-2 aligned map sizes (64 blocks, 128 blocks, and 256 blocks) so the shift-factor could be pre-computed to avoid division/multiplication, which was dang slow on those old 386/486 computers. Each map block was 2x2 cells, and each cell, 8x8 pixels. Made rendering background cells and fog-of-war overlays very straightforward assembly language. All…

If you worked on Lost Vikings I'd like to thank you for the entertainment during my childhood. Given your background did you ever get involved in the demo scene?

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#92

Warcraft 1 (1994), Warcraft 2 (1995), and StarCraft (1998) all use power-of-2 aligned map sizes (64 blocks, 128 blocks, and 256 blocks) so the shift-factor could be pre-computed to avoid division/multiplication, which was dang slow on those old 386/486 computers. Each map block was 2x2 cells, and each cell, 8x8 pixels. Made rendering background cells and fog-of-war overlays very straightforward assembly language. All…

Were you at blizzard when they lost their source code server and had no backups? I was there for a short time consulting around the time WC3 was released.

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#93

> The same trick can also be used for the other direction to save a division: NewValue = OldValue >> 3; This is basically the same as NewValue = OldValue / 8; RCT does this trick all the time, and even in its OpenRCT2 version, this syntax hasn’t been changed, since compilers won’t do this optimization for you . (emphasis mine) Not at all true. Assuming the types are such that >> is equivalent to /, modern compilers w…

they will do it for unsigned. for signed they will do a bit more to do the same rounding as C promises

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#94
post #77
post #45

Earlier quoted context omitted.

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.

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.

That's the second time I heard the beaver game come up here... Guess I really ought to try it!

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#95

> Imagine a programmer asking a game designer if they could change their formula to use an 8 instead of a 9.5 because it is a number that the CPU prefers to calculate with. There is a very good argument to be made that a game designer should never have to worry about the runtime performance characteristics of binary arithmetic in their life, that’s a fate reserved for programmers Numeric characteristics are absolutel…

Constraints breed creativity.

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#96
post #67

Earlier quoted context omitted.

> Numeric characteristics are absolutely still a consideration for game designers even in 2026, one that influences what numbers they use in their game designs. The good ones, anyways. I used to think like this, not anymore. What convinced me that these sort of micro-optimizations just don't matter is reading up on the cycle count of modern processors. One a Zen 5, Integer addition is a single cycle, multiplication 3…

Also, it's unusual for a game to be CPU bottlenecked nowadays, and if it is, it's probably more constrained on memory bandwidth than raw FLOPS.

Yes, though it depends a bit on your style of game.

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#98
post #15
post #4

What language is this article talking where compilers don't optimize multiplication and division by powers of two? Even for division of signed integers, current compilers emit inline code that handles positive and negative values separately, still avoiding the division instruction (unless when optimizing for size, of course).

That's what I would have thought as well, but looks like that on x86, both clang and gcc use variations of LEA. But if they're doing it this way, I'm pretty sure it must be faster, because even if you change the ×4 for a https://godbolt.org/z/EKj58dx9T

Using an lea is better when you want to put the result in a different register than the source and/or you don't want to modify the flags registers. shlx also avoids modifying flags, but you can't shift by an immediate, so you need to load the constant into a register beforehand. In terms of speed, all these options are basically equivalent, although with very slightly different costs to instruction caches and the register renaming in the scheduler. In terms of execution, a shift is always 1 cycle on modern hardware.

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#99
post #77

Earlier quoted context omitted.

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.

That's the second time I heard the beaver game come up here... Guess I really ought to try it!

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.

Re: The gold standard of optimization: A look under the hood of RollerCoaster Tycoon

#100
"Since the number is stored in a binary system, every shift to the left means the number is doubled.

At first this sounds like a strange technical obscurity"

Do we not know binary in 2026? Why is this a surprise to the intended audience?

Post reply on HN