AI Distillery

Battle Isle 2 reimplementation

Multiple people shared their old game reimplementation efforts recently, starting with projects where the author had access to source code of a port, to a version of Supreme Commander. Very cool work.

Sometime in spring, I started to look into one of my favorite games - Battle Isle 2. A turn-based strategy game with very good presentation for its time: beautiful units, maps that use color well and a great electronic soundtrack. There are animated 3D rendered fights, mission briefings display as animated video calls. Blue Byte tried to make the best strategy game possible and I think they pretty much succeeded.

Battle Isle 2

I still love playing the game to this day, it runs well under DOSBox and is available on GOG. The control scheme is a bit clunky, on mouse down the cursor moves to the bottom of the screen where you select the action. You can play with the keyboard, except single presses are often interpreted as double, making selecting units difficult.

A few years ago, kitana did a reimplementation for Windows, Battle Isle 2020. I played it for a short time, the author has modernized the game very well - text-to-speech for announcements, scaled graphics, better AI, new missions - amazing work. I tried a reimplementation a few years ago and was looking at BI 2020 as a possible source. Back then, I couldn’t make sense of the PowerBASIC code, couldn’t find a compiler to build it and quickly gave up.

Building the spec

I decided to build a new port to fix controls and to be able to play on my phone. The first version runs in the browser and controls are much worse than in the original. I’m currently resolving some loose ends to have a playable version in a PWA.

Different from before, I decided to start with the spec of the game - all data files first, then the game logic. I now have good coverage of the data files. While there are a few missing fields, I think the spec makes almost the whole game playable. For the remaining few missing bits, I’m not sure they are even used in the game.

The game logic is trickier. If I did it again, I would follow the same pattern other AI ports are doing. I would have skipped the spec and gone straight for the new implementation, letting an agent port individual functions or parts of the code. I’m glad I started earlier as it allowed me to better understand how the game works. If you are interested, you can browse the partial spec for the data files. While I have the full spec in my repository, it’s not in a readable state yet.

In earlier stages, I let the agent ask me questions about behaviour and I controlled the game to find the answers. These answers were collected as the acceptance test suite that I’m still using. This is of course very slow. Eventually, I configured the agent to run the steps on its own, letting a small agent control DOSBox and trace what happens.

Agent control of DOSBox was dreadfully slow, taking ten minutes for a few clicks. It used accessibility APIs on macOS to trigger clicks and take screenshots of the window. DOSBox-X has a good debugger where the agent can trace what happens and GameLink support adds fast access to input and screenshots. I created a small local patch to allow parallel DOSBox windows to be controlled at the same time, better mouse handling and permissions to work well with agents.

Today’s status

The web port is not playable yet. It’s possible to move units, do attacks, undo moves. The spec already supports mission triggers, weather and construction, but the web implementation lags behind. If you’d like to try it, you’ll need your own Battle Isle 2 GOG copy. Run the exe to extract the CD image and ogg files, then upload them to the web version. The UI is very clunky, but you can then start any mission, move units around and make attacks.

You can also play around with some of the spec files - e.g. the full list of units extracted from the game, including their 3D meshes and animations, the spec of the unit files or maps. I’m cleaning up my findings to publish the rest.

I also prototyped a new 3D battle version, or you can configure it here:

Last, I fixed some bugs in existing missions and animations, you can download the fixes for the original game.