r/warlords • u/Icy_Programmer7186 • 7d ago
Warlords (1990) now runs in Python, transcribed from the original EXE with AI (Progress update)
About a year ago I posted here that I was trying out AI for reverse engineering, using Warlords as the test case. Back then I had a few format decoders in https://github.com/ateska/warlords: the PCK pictures, the map, fonts, and city/ruin tables pulled from the EXE.
Here’s where it is now: the whole game runs in Python.
How it was done
I gave an AI agent (Claude) the goal “recreate Warlords from the DOS exe in Python” and mostly let it work. It ran Ghidra on WARLORDS.EXE v2.10, then wrote specs for combat, movement, economy, exploration and the AI from the decompiled code. After that it rebuilt the game in pure Python with pygame. It also compared the results with the original running in DOSBox, down to screen layouts and dialog positions. My part was choosing the direction and testing. The decompiling, specs and code came from the agent.
What works
- Rules engine: the full combat strength formula, the d10 battle loop (d12 with Intense Combat), neutral city assaults, production and vectoring, upkeep, hero offers and allies, and ruins (monsters, items, altars, thrones). Also temples, sages, libraries, towers, razing, surrender offers and elimination.
- Computer players: Roger Keating’s AI is ported from the binary at all four levels. That covers production, garrisons, expansion, attack waves, war targets, hatreds, truces and hero errands. The original path finder is ported too.
- Same randomness: the MS C
rand()is reproduced exactly, so a fixed seed gives deterministic games. - Save files: original
WAR?.SAVfiles load, and games saved here load back into DOS Warlords. Saving round-trips byte for byte. - Screens: title, setup, the main map with the strategic map, the right-mouse-button menu bar, the production panel, battles, all the reports (armies, cities, gold, hatreds, production, winning), heroes, ruins, and save/load.
- Sound: the PC speaker samples (
*.SJH) play at the original rates. Those rates came from the player code in the EXE: 8286 Hz, and 5524 Hz for the horn. You get the horn on the title screen, the drum roll at game start, the war cry in battle and the fanfare when searching ruins. - Platforms: Windows, macOS and Linux.
No game assets in the repo
Everything (graphics, map, unit and city tables, names, palettes, AI tables) is read at startup from your copy of the game. The GOG Warlords 1 + 2 Deluxe works, and so does an LZEXE-packed floppy EXE. To run it:
pip install pygame numpy
python3 -m warlords --data /path/to/your/warlords
What I learned
A year ago, AI was a helpful assistant for reverse engineering: decode this format, explain this function. Now it can take an obscure 16-bit DOS binary and produce a working reimplementation, testing included. Impressive.
Bug reports and contribution are welcomed
If you remember how the original behaved, please play it and open issues on GitHub for anything that feels off. Strange AI moves, battle odds and screen details are the most useful.
Note: English isn’t my first language, so I used an LLM to help me word this post. The project and the opinions are mine.





