HN
Today

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

RollerCoaster Tycoon remains a benchmark for optimization, famously coded almost entirely in Assembly by Chris Sawyer. This deep dive unpacks the clever technical and design choices, like granular data types, bitshifting arithmetic, and performance-driven game mechanics, that allowed it to run thousands of agents on 1999 hardware. HN revisits this engineering marvel, sparking debate on compiler capabilities and the enduring relevance of performance-conscious game design.

122
Score
41
Comments
#2
Highest Rank
24h
on Front Page
First Seen
Mar 22, 8:00 PM
Last Seen
Mar 23, 7:00 PM
Rank Over Time
1232433222224476699101014182022

The Lowdown

The 1999 classic RollerCoaster Tycoon is lauded for its remarkable optimization, simulating entire theme parks with thousands of agents on modest hardware. This article delves into the techniques used by its creator, Chris Sawyer, leveraging the reverse-engineered OpenRCT2 project to reveal the genius behind its efficiency.

  • Assembly Language: While Assembly was the dominant language for games, RCT was an outlier for its time, written almost entirely in it. This allowed for granular control and performance, though modern compilers have significantly narrowed the gap with high-level languages.
  • Aggressive Data Typing: Money values across the game were stored using the smallest possible data types (e.g., 1-byte for shop item prices, 4-bytes for park value), maximizing memory and processing efficiency.
  • Bitshifting for Arithmetic: The game extensively used bitshifting (e.g., >> 3 instead of / 8) for multiplication and division by powers of two. This indicates game formulas were specifically designed to utilize such numbers for faster calculations.
  • Game Design for Performance: Sawyer, as both designer and programmer, made fundamental design choices to optimize performance.
    • "Blind" Pathfinding: Guests don't pathfind to specific attractions. Instead, they wander, reacting to nearby rides. Pathfinding is only used for critical agents (mechanics, guests leaving) and is strictly limited in search depth, sometimes failing (leading to in-game complaints) to prevent framerate spikes. A map item increases this limit, making it a gameplay feature.
    • Collisionless Crowds: Guests don't collide or avoid each other, allowing thousands to occupy the same path tile. Overcrowding is handled by guests negatively reacting to high density, not by complex physics, simplifying calculations significantly.

Ultimately, RCT's optimization was a "perfect storm" of Chris Sawyer's dual role, allowing deep integration of technical constraints into game design. The article concludes that while today's development differs, fostering dialogue between coders and designers remains crucial for intelligent optimization.

The Gossip

Compiler Controversies

The article's claim that "compilers won't do this optimization for you" regarding bitshifting for division sparks immediate disagreement among commenters. Many assert that modern compilers are indeed smart enough to convert division/multiplication by powers of two into bit shifts or use instructions like LEA (Load Effective Address) for optimization, especially when integer types and rounding rules allow for it. However, some acknowledge edge cases, like signed integer behavior, where compilers might be conservative.

Design Dictates Data

Commenters largely agree with the article's core point that game design decisions, particularly numeric characteristics and data structures, profoundly impact performance. They argue that good game designers still need to understand these low-level considerations. Examples like Factorio's optimization, Minecraft's use of 4-bit values for block attributes, and the original World of Warcraft's item ID system are cited as modern instances where design choices are driven by underlying data efficiency.

The Human Optimizer's Edge

Many commenters emphasize that while compilers are powerful, they cannot replicate the 'human optimization' that Chris Sawyer achieved. This human advantage lies in the ability to deliberately break abstraction layers, integrate technical limitations directly into game mechanics, and make fundamental design compromises for performance, something an automated compiler cannot decide to do.