Metrostroi – Subtransit Prototype

It may be interesting to mention where Subtransit originated from. Before the development of the game started, I was working on what effectively became the prototype for the game. It was an addon for Garry’s Mod, which initially was just a fun test to see if nice trains could be implemented using Source Engine physics.

Initially, the mod only had trivial simulation of the train systems. It was a very arcade-like model, as having proper moving trains in Garry’s Mod was a huge novelty at the time. The trains utilized collisions provided by Havok to stay on the rails – effectively simulating behavior of flat wheels on flat rail heads… and very very low polygon curves.


This addon served as a prototype from which the ideas for Subtransit were derived – especially the social aspects and the importance of the multiplayer mode for a subway train simulator. It also served an additional important purpose – it was a test of the failure simulation part of the internal systems simulator framework (while it did not use the framework itself, the failure simulation in the framework was based on this prototype).

The graphics in Source Engine were really bad. To make the matters worse, the engine limited the maps to 1.2 x 1.2 x 1.2 km cube. Still, I’ve managed to fit about 100 km of tracks into that volume! That meant the tracks would always go spiraling down the map under pretty intense slopes.

After about a year of messing around with basic train motion, I have decided to create a much more detailed simulation of the trains. Luckily, technical data was well available for a Ezh3RU1 train. The systems code in Metrostroi was just a small framework I wrote specifically for that project, written entirely in Lua. While initially it was entirely Garry’s Mod Lua based, eventually the train systems were simulated in a separate LuaJIT environment with a special DLL.

This prototype simulator is open-source and a bunch of people have since continued the development. The original code is available on Metrostroi GitHub. Needless to say, the code in Subtransit shares very little with Metrostroi code.

While Metrostroi had multiplayer support from the very beginning, performance issues always plagued it. I think the latest version permits only 6-7 wagons on the server. Even though the actual train simulation was mostly off-loaded to a separate thread, Garry’s Mod Lua seems to be inherently slow. There is no distinct bottleneck, but every little part of the code is contributing to overall inefficiency.


Metrostroi demonstrated two important things that have led to Subtransit development:

  1. Intricate simulation of train behavior results in many interesting and fun situations. It’s fun to drive rheostat-based trains due the low-level access to the electric circuits!
  2. Being able to do everything in a group of friends makes the experience even better

The development of Metrostroi was stopped just about the time when early development of the new simulator started. It is still supported by the Russian metro trainfan community, who have added a bunch of new train models into it (although nothing has been changed in the systems simulation). Metrostroi can also be downloaded from the Garry’s Mod Workshop.