Skip to main content
The cover image for "Why OpenTTD cities stop growing, and how to reach a million"

Why OpenTTD cities stop growing, and how to reach a million

Sidebar

I've been playing OpenTTD for many years. Recently, I decided to freshen things up by setting a challenge: focus on a single city, getting it to 1 million population with high service coverage. I evenly spaced out 2-tile long stations in a grid pattern with alternating directions, with tram and buses providing perpendicular connections. Using this design, I was able to provide near 100% coverage for mail and passengers. However, I discovered two things by doing this. First, this is a boring way to play that creates monotonous cities. Second, my cities stopped growing at around 80-100,000 population. Why did my cities hit a ceiling? I set out to understand OpenTTD's town growth algorithm to find out why. I read the code, ran experiments inside real OpenTTD, and created simulations shown in this article.

I’ve been playing OpenTTD for many years. Recently, I decided to freshen things up by setting a challenge: focus on a single city, getting it to 1 million population with high service coverage.

I evenly spaced out 2-tile long stations in a grid pattern with alternating directions, with tram and buses providing perpendicular connections. Using this design, I was able to provide near 100% coverage for mail and passengers. However, I discovered two things by doing this. First, this is a boring way to play that creates monotonous cities. Second, my cities stopped growing at around 80-100,000 population.

Why did my cities hit a ceiling? I set out to understand OpenTTD’s town growth algorithm to find out why. I read the code, ran experiments inside real OpenTTD, and created simulations shown in this article.

What controls how fast a city grows? #

Growth rate #

Each town in OpenTTD has a timer. When the timer hits zero, it attempts to grow the town. Each successful growth attempt places a house or a roadfootnote 1. The time between attempts is called the growth_rate and depends on a few factorsfootnote 2footnote 3footnote 4:

  • The town’s size, in number of buildings. Bigger cities grow faster.
  • Whether the town is a city. Cities grow twice as fast.
  • How many stations were served in the last 50 days (up to five).
  • Whether a player is funding new buildings.
  • The town growth speed setting.

Maximum city growth can be achieved with just five stations #

From the above, we now know that you only need five stations with passengers and goods being loaded or unloaded in the last 50 days to achieve maximum growth. That’s it. The city could be huge with terrible coverage, the five stations only in the centre, and terrible service rating and it’ll still grow just as well. This meant that all the stations I added after the first five did not contribute to growth, just to service coverage and income.

This does not explain why my cities reached a limit, but does explain why the growth feels unsatisfying.

There’s a minimum wait between attempts, even when unsuccessful #

The minimum time between growth attempts, no matter the settings or funding, is 0.95 days or 70 ticks.

At a certain point, a city grows enough that the time after a successful attempt is the same as the time after a failed attempt. This means that failures cost the same as successes, and a city’s growth rate comes down to how often the growth fails.

So, how can an attempt fail?

Why do cities stop growing? #

The town growth algorithm is a random walk #

Cities decide where to place a new road or building using a ‘random walk’. They start at a road on or near the centre tile and then take random turns at junctions until they reach an unoccupied tile, a dead end, or run out of timefootnote 5. After a success or failure, the algorithm waits for a period of time based on the growth rate.

Lots of junctions can cause the algorithm to get lost #

This is true, but not when using the default road layout (original).

At the time of writing, if you search the Internet for what limits OpenTTD city growth, it will tell you that the problem is due to lots of junctions around the centre causing the random walk to get lost. As the random walk takes a random direction at each junction, it can end up looping on itself and running out of timefootnote 6footnote 7.

We can test this by switching from original to better roads. The better roads layout halves the number of junctions by adding a minimum distance between them. This also allows the city to spend more time building houses than roads.

In the above simulation, we can see that better roads grows faster than original but it still levels off. Original has over 2x more junctions for the same population size as better roads. If junctions were the main reason, I’d expect a larger improvement.

Let’s have a look at the reasons for the last 200 failed attempts:

Reaching a dead end massively dominates the failures. In most cases when I run this simulation, I don’t see “ran out of steps” at all.

Original and better roads produce dead ends that limit growth #

The original roads and better roads layout result in a lot of dead ends, which causes the algorithm to fail and wait for the next growth attempt. In the below simulation, we compare original roads vs a 3x3 grid:

Notice how the original layout’s failure rate spikes massively to over 90%, whereas the 3x3 grid rate stays low.

Dead ends aren’t possible in an unmodified 3x3 grid on open, flat land, so the failures are now dominated by the random walk getting lost on junctions. Because the 3x3 grid’s failure rate stays low, it doesn’t reach a similar plateau as original or better roads. The random walk getting lost slows growth, it doesn’t limit it.

If you don’t want to use a grid, you can instead turn off “Towns are allowed to build roads” and build the roads yourself, ensuring that there are no dead ends in the layout.

We can reproduce this result in-game:

Better roads vs 3x3 grid, 1950-2051, on very fast growth (simulations above are on normal)
Better roads vs 3x3 grid, 1950-2051, on very fast growth (simulations above are on normal)

Renovation #

Renovation is the final way that city growth is limited. It applies to every city no matter the layout, and the limit is much higher - in the millions. This will be discussed in “What’s the biggest city that is possible?”.

How to grow huge cities #

Growth tunnels aren’t worth it #

One of the techniques I discovered online is creating growth tunnels. Growth tunnels are built between a city’s centre and the outskirts, and provide a shortcut for the growth algorithm.

The exit of a growth tunnel. The entrance is right by the city centre. This allows the growth algorithm to skip large parts of the city.
The exit of a growth tunnel. The entrance is right by the city centre. This allows the growth algorithm to skip large parts of the city.

Growth tunnels are most effective on road layouts that have a high growth failure rate. They should provide much less of a benefit with prebuilt grid layouts. My experiments have found that other techniques are more effective and produce an almost zero failure rate, and therefore you don’t need to use growth tunnels.

In the simulation below, you can see how they improve growth - to a point. Unfortunately, they delay the problem but do not fix it.

Prebuild a grid and use the original/better roads layout #

We can achieve much higher growth by using the original layout with a prebuilt 3x3 grid, with “Towns are allowed to build roads” turned off.

This is because of two reasons:

  • The number of steps before the random walk gives up is based on the road layout. The original road layout’s limit is 4 times higher than the 3x3 grid.
  • On each successful growth attempt, the town either places a building or a road. By prebuilding roads, we ensure that all of the growth effort goes into building houses and not roads.

If turning off towns build roads isn’t an option, you can use the better roads layout (which won’t build roads inside the grid) at the cost of a lower step limit.

Dual spirals #

Now that we know how the growth algorithm works, we can achieve faster growth by designing the road system in its favour. The most efficient method is to prebuild a road layout that has no junctions at all, allowing the random walk to always complete successfully. To do this, turn off “towns are allowed to build roads” and instead place roads yourself in a dual spiral going out from the centre.footnote 7:1

Even though the city cannot place roads, you’ll need to use the original roads layout as it has a higher step limit before it gives up.

The population and failure rate are reasonably close between these two approaches. The spiral ends up about 8% bigger (roughly 100,000 people), purely due to the distribution of its buildings and shape of the city - more end up in the most dense inner zone. In my experiments, a grid’s centre zone was 56% houses, against 66% for a spiral.

The spiral breaks immersion and looks pretty awful in my opinion.

Powerfunding #

When you fund a town, a faster base growth table is used for 3 months, cutting the wait between attempts by about 40%. Each time you fund, the next growth attempt is cut to at most 2 days. Powerfunding is when you fund a town every couple of days so that the town tries to grow every 2 days, no matter the growth rate.

A small town with five stations takes quite a while between growth attempts - 48 days unfunded, 29 days funded. Once the growth rate is naturally below 2 days, powerfunding stops helping and normal funding is enough.

In my experiments with a spiral and stopping, after 100 years a town reached 1.844 million with powerfunding versus 1.765 million without. That’s an additional 78,000 people.

At a certain point, a growing town reaches the fastest growth rate and can grow no faster. By using funding, you can give a town a head start to reach this point faster and stay ahead for the rest of the game.

Stopping growth just before the end #

Renovation only happens to growing towns and houses take a while to build. If you stop all transport and funding four months before the end of the game, it gives time for houses to finish building and prevents existing houses from being destroyed.

In my experiments, I found this technique added 94,000 more people to the final total.

What’s the biggest city that is possible? #

Is there a limit to how big a city can grow in OpenTTD? The answer is roughly 2.3 million, or nearly 2.5 million with the stopping technique, and it’s due to the renovation mechanicfootnote 8.

Every year, 1/3 of a growing city’s buildings are demolished. This only happens to buildings above a minimum age. This allows the city to replace older buildings and increase density as the city grows. 95% of the time, the building is immediately rebuilt. 5% of the time, the tile is left empty.

This means that 1.5% of buildings are lost each year. At the fastest growth rate, a city can only grow 385 times a year. When a city reaches roughly 2.3 million population, the number of buildings lost per year to renovation matches the growth rate, and the city will no longer grow. This assumes that growth attempts never fail.

OpenTTD's maximum town population is 2.3 million, or roughly 2.5 million with the stopping technique as shown here.
OpenTTD's maximum town population is 2.3 million, or roughly 2.5 million with the stopping technique as shown here.

Conclusion #

In summary, growth is capped to one attempt every 0.95 days, and five stations are enough for full growth. To achieve the highest population, you need to increase the chance of successful growth attempts that result in houses. Dead ends limit the original and better road layouts to about 100,000 population. Prebuilding roads allows the town to build houses rather than roads, and a grid or spiral layout with the original road layout reduces the chance of the town giving up.

My experiments inside OpenTTD were done in an ideal scenario - infinite money, perfectly flat terrain, with five stations consistently serviced. This gives us a theoretical upper bound, but a real game is likely to be lower.

The simulations (source) are based on a port of OpenTTD’s code (town_cmd.cpp) to JavaScript. They run on a simplified world model, with no hills, rivers, or player constructions. All of these things may further slow down growth. Additionally, it doesn’t simulate house selection; the population is estimated and may not be accurate.


  1. On the Better roads and 3x3 grid layouts, sometimes two houses will be placed. A house and a road can also both be placed in one attempt. Also note that a house can span multiple tiles. ↩︎

  2. Towns: Town Growth - OpenTTD Wiki ↩︎

  3. How do you grow towns in OpenTTD? ↩︎

  4. GetNormalGrowthRate - town_cmd.cpp - OpenTTD ↩︎

  5. GrowTown - town_cmd.cpp - OpenTTD ↩︎

  6. Junctions misconception on Reddit ↩︎

  7. Taking on PotatoMcWhiskey’s OpenTTD 100 Year City Growing Challenge - Master Hellish ↩︎ ↩︎

  8. 2.5M population: u/citymaniac on r/OpenTTD - Reddit ↩︎

rubenwardy's profile picture, the letter R

Andrew Ward

Hi, I'm Andrew Ward. I'm a software developer, an open source maintainer, and a graduate from the University of Bristol. I’m a core developer for Luanti, an open source voxel game engine.

Comments

Leave comment

Shown publicly next to your comment. Leave blank to show as "Anonymous".
Optional, to notify you if rubenwardy replies. Not shown publicly.
Max 1800 characters. You may use plain text or Markdown.