---
title: 'For developers'
url: 'https://openth.org/community/developers'
markdown: 'https://openth.org/community/developers.md'
lang: en
date: '2026-11-26'
description: 'For developers OpenTH adds online multiplayer to CorsixTH, the open-source remake of Theme Hospital. All of it is open source under the MIT licence, on GitHub. This page is for people who want to test new builds or work on the code. Help test Testing is the most useful help right now, and it needs …'
---

# For developers

OpenTH adds online multiplayer to CorsixTH, the open-source remake of Theme Hospital. All of it is open source under the MIT licence, on [GitHub](https://github.com/openth-org/openth). This page is for people who want to test new builds or work on the code.

## Help test

Testing is the most useful help right now, and it needs no programming.

1. **Get the test build.** Test builds are the pre-releases on [GitHub](https://github.com/openth-org/openth/releases), and the newest one runs on the test server. Recent versions of the game offer to download the server's version by themselves when you connect.
2. **Play on the test server.** In the main menu, click **Multiplayer**, then **EU2: test builds**. Bring friends; the room's host can also click an empty place to add a bot.
3. **Try what is new.** Each release's notes say what changed. That is where new bugs hide.
4. **Tell us what you find** on [Discord](https://openth.org/discord) or as a [GitHub issue](https://github.com/openth-org/openth/issues): the server, the room name, roughly when it happened and what you were doing. Attach the newest file from the game's `Logs` folder. If the game went out of sync or stopped, say so: the server keeps a log of every game.

The [player's guide](https://github.com/openth-org/openth/blob/master/docs/multiplayer/PLAYING.md) explains every multiplayer screen and rule.

## How the multiplayer works

Every player's computer runs the whole game: every hospital, every patient, every rat. The network carries only what the players do (commands, a few a minute) and a short fingerprint of each game step (about 18 a second). Each computer works out everything else by itself, from the same start and the same commands, applied at the same game hour. This is **deterministic lockstep**, the classic way strategy games do multiplayer.

| Part | What it does | Code |
|---|---|---|
| The game | CorsixTH with the multiplayer code in Lua: lockstep, commands, the lobby and the connection | `CorsixTH/Lua/mp_session.lua`, `mp_lobby.lua`, `mp_transport.lua` |
| The server | A small Python program: rooms, the version check, pacing, passing messages between the players, comparing fingerprints, organising repairs. It never simulates the game itself. | `mp_server/corsixth_mp/` |
| The referee | One more copy of each game on the server, without a screen. It checks the players, repairs a game that drifts apart, and lets players join a game that is already running. | `scripts/multiplayer/referee.lua` |
| Bots | Computer players. Each one is the game without a screen, started by the server, playing through commands like a person. | `scripts/multiplayer/bot.lua`, `bot_manager.lua` |

**The hard part** is making Windows, Linux and macOS compute the very same hospital, hour after hour. That took one shared random number generator (and a second one for what only one player sees), a fixed order wherever Lua's own order differs between computers, the same Lua version in every build, game rules sent by the server instead of read from each player's settings, and commands that name things by number, never by text, so players with different languages can play together.

**When games drift apart anyway,** the server notices, because it compares every step's fingerprints. Everybody then loads the referee's copy of the game, and play goes on. Each game also logs what it knows, so the cause can be found afterwards.

**Single player stays as it was.** Everything multiplayer sits behind one session object, and a test of three game years checks that every new build plays single player exactly like the one before.

## Documentation on GitHub

| Document | What it covers |
|---|---|
| [How it works](https://github.com/openth-org/openth/blob/master/docs/multiplayer/HOW-IT-WORKS.md) | A tour for programmers: the parts, lockstep, keeping computers in step, repairs, and where to read the code |
| [Protocol](https://github.com/openth-org/openth/blob/master/docs/multiplayer/protocol.md) | Every message between the game and the server |
| [Referee](https://github.com/openth-org/openth/blob/master/docs/multiplayer/referee.md) | Repairs, joining a running game, players whose Theme Hospital files differ |
| [Bots](https://github.com/openth-org/openth/blob/master/docs/multiplayer/bots.md) | What the computer players do and how they decide |
| [Co-op architecture](https://github.com/openth-org/openth/blob/master/docs/multiplayer/coop-architecture.md) | Several hospitals in one world |
| [Developer handover](https://github.com/openth-org/openth/blob/master/docs/multiplayer/README.md) | Building, testing, branches and the lessons learned |
| [Server guide](https://github.com/openth-org/openth/blob/master/mp_server/README.md) | Running a server, playing on a LAN, every setting |
| [Public server setup](https://github.com/openth-org/openth/blob/master/docs/multiplayer/SERVER-SETUP.md) | A server with the referee and bots, as on our own servers |

OpenTH shares its engine with CorsixTH, so CorsixTH's developer wiki applies here too: [how to compile](https://github.com/CorsixTH/CorsixTH/wiki/How-To-Compile), [coding conventions](https://github.com/CorsixTH/CorsixTH/wiki/Coding-Conventions), [Lua and C](https://github.com/CorsixTH/CorsixTH/wiki/Lua-And-C), the [Lua console](https://github.com/CorsixTH/CorsixTH/wiki/Lua-Console) and [debugging](https://github.com/CorsixTH/CorsixTH/wiki/Debugger-Tutorials).

## Work on the code

- **The languages:** the game is Lua and C++ (it is CorsixTH underneath), the server is Python.
- **Branches:** the work happens on the `mp/team-hospitals` branch; send pull requests there. `master` holds the stable release.
- **Checks:** every change runs the Lua checks (luacheck), the unit tests (busted), the server tests (pytest) and real games through the lobby that must stay in sync. If you change the simulation (the world, hospitals, people), also run the single-player test.
- **AI-assisted code is welcome.** What matters is that a change is understood, tested and reviewed.
- **Where to start:** say hello on [Discord](https://openth.org/discord) and tell us what you would like to do, or pick an [open issue](https://github.com/openth-org/openth/issues).

---

## Navigation

- Parent: [Community](https://openth.org/community.md)
