Xenon 2: Megablast is a vertically scrolling shoot ‘em up from 1989, designed by the Bitmap Brothers and developed with the Assembly Line. You fly a small ship through beautifully drawn organic scenery, shoot things, collect upgrades, and occasionally visit an alien shopkeeper called Colin.
It is a game in which buying a better gun is a sensible financial decision.

You can play the browser version yourself.
I wanted to see whether GitHub Copilot could help turn the original DOS game into a native browser application. Not put an emulator in a web page, but recover the behaviour from the binary and recreate it in JavaScript.
That was already an interesting experiment. Then I wondered whether an AI could play the result.
This became two connected projects: an AI-assisted reconstruction of an old application, and a laboratory for testing an AI player. Along the way there were local models that refused to steer, a spaceship that spent several minutes arguing with a rock, a genuinely defeated boss, and a fairly decisive lesson about network latency.
Starting with an executable, not the source
The starting point was XENON2.EXE, a 123,496-byte, 16-bit DOS executable, plus
the original graphics and level files. There was no source tree to translate.
The game itself first appeared in 1989 on the Amiga and Atari ST. The PC version I used was released in 1993. I was basically working with a 33-year-old MS-DOS game.
“Decompiling” is useful shorthand, but this wasn’t an automatic EXE-to-JavaScript conversion. The work involved disassembling the 8086 machine code, identifying routines and data structures, understanding what they did, then expressing that behaviour in native code.
Copilot did the code exploration, implementation and tool-building, with me directing the work and questioning the results. I wasn’t manually transcribing every instruction. Equally, a plausible-looking answer from the coding agent wasn’t enough to establish that it had recovered the game correctly.
First came the data formats: compressed sprite banks, palettes, planar graphics, tile maps, enemy events and movement paths. The executable contained the routines that knew how to read these formats, so it was both the thing being investigated and a source of evidence.
For example, the compressed graphics used adaptive Huffman coding and an LZ-style dictionary. Recovering a decoder meant the browser could use the original artwork rather than approximations downloaded from somewhere else.
Then came movement, collisions, weapons, enemy behaviour, bosses and shops. The goal was to recover the rules, not write a vaguely similar space game.
The result uses JavaScript and Canvas 2D. There is no CPU emulator in the running browser game. Emulation was a development tool, not its runtime.
The PC version had very basic sound, so I used audio from the Amiga version for the browser game instead. That was a deliberate upgrade, rather than an attempt to reproduce the DOS audio.
The reconstruction’s source includes the headless controller work described below.
Making the original code answer questions
The most useful technique was to keep the original machine code available as an executable reference.
Rather than deciding that a translated routine “looked right”, the verification tools execute the original 16-bit instructions in Unicorn, a CPU emulation framework, and compare the results with JavaScript:
Known starting state
|
+--> Original 8086 routine in Unicorn --> Original result
|
+--> Reconstructed JavaScript routine -> Native result
|
Compare the two
The harness loads the DOS image, applies its relocation entries, sets up the registers and memory, and calls a particular routine. DOS file operations can be intercepted so the original decompressor reads the supplied data without needing to boot the whole game.
This gave us several useful levels of comparison:
- Decoded data: do both decompressors produce exactly the same bytes?
- State traces: after the same updates, do positions, fixed-point fractions, health, animation state and random-number state agree?
- Interactions: which object is hit first, when does a pickup appear, and what happens when an object slot is reused?
- Pixels: do recovered drawing routines and the native renderer produce the same indexed-colour screens for the scenes being checked?
Browser tests then exercised the reconstructed application in Chromium. The emulator tests checked recovered behaviour; the browser tests checked that the pieces actually worked together in their new environment.
There were some wonderfully awkward details.
Movement used fixed-point arithmetic. Collision checks could happen before the player moved, rather than after. Reusing an enemy’s slot could affect what was updated or drawn next. Replacing these with tidier-looking code could change the game.
Even Colin’s face mattered.

The shop’s portrait animations and cabinet effects consume the same random
number generator used elsewhere. Skipping those animations and directly
granting a purchase would change the later random sequence. For faithful
replay, the shop needed its real selection, quotation, confirmation and
animation updates, not just a call to buy().
Keeping the game, fixing the bugs
Some discrepancies turned out to be bugs in the supplied DOS executable, rather than mistakes in the JavaScript translation. We decided to fix these in the JS version instead of reproducing them:
- The stage-two boss’s disappearing explosions. Creating the credit rewards overwrote a register that the death routine then used to read the boss’s vertical position. It read unrelated map data instead, placing all thirty explosions offscreen. The JavaScript version saves the boss’s position before creating the rewards, preserving the original explosion spread and random calls.
- Enemy shots using the wrong aiming information. The original code calculated the vertical distance to the player in one register, but the direction helper read another register containing unrelated state. We made foreground enemies aim using the actual horizontal and vertical differences, retaining the original eight-direction aiming, firing cadence and projectile speed. This can change the difficulty; it is a deliberate correction, not an exact reproduction.
- The stage-three worm’s stuck projectile animation. Its animation timer was initialised from a sprite pointer instead of the following duration word, leaving the first frame held. The port plays the recovered four-frame sequence at two ticks per frame, without changing movement, damage or expiry.
The browser also prevents the same continue reward from being granted twice if the campaign-completion flow runs again.
These were specific, documented choices, not a general invitation to “improve” anything that looked odd. Other unusual behaviours were retained. These findings also relate to this DOS binary; we didn’t establish equivalent bugs in the Amiga version.
This still wasn’t proof of perfect whole-game equivalence. There are documented approximations, and for the three routine fixes above the verification harness applies explicit corresponding corrections to the original instructions in memory. Those comparisons check the corrected behaviour, not parity with the unmodified game. The original executable on disk remains untouched.
The useful lesson was simpler: the old executable can be a test oracle, not just something to read.
Taking the screen and clock away
Having the game logic in JavaScript opened up another experiment: could an AI take over from the human player? I could give a model the current scene, ask it to choose steering, firing or diving controls, and let the engine apply its decision. To try that, I needed to separate playing the game from displaying it.
Once the simulation was separate from the browser, it could run in Node.js with no window, keyboard, audio or web server.
Rendering became optional. The same engine could either produce state for a controller or use the existing Canvas renderer to capture PNGs.
More importantly, simulation time no longer had to follow wall-clock time.
The recovered DOS timing works out at about 18.2068 simulation ticks per second. For the initial AI experiments, one decision controlled four ticks, roughly 220 milliseconds of gameplay:
Observe the game
-> Ask the model
-> Validate its choice
-> Apply controls for four simulation ticks
-> Observe again
Nothing advanced while the model was thinking. A response could take a second, or ten seconds, without the ship moving into something in the meantime.
This also made recording straightforward. We saved the starting seed, exact inputs, actual tick counts and resulting state. Optional PNG capture recorded every simulation tick, including the ones between decisions.
A video assembled at the native tick rate showed the game at its intended speed, regardless of how long inference had taken. A smooth-looking video was therefore not evidence of a real-time AI player.
The action log could also replay the actual engine without any further model calls. This let us check native state and pixels, rather than merely animate a saved list of ship coordinates.
What should the AI see?
The obvious interface was screenshots. That would make an interesting test of visual understanding, particularly with consecutive frames to show motion.
I was thinking about decision models as well as running a smaller model locally. The local models I was considering weren’t multimodal: they could read text, but not interpret gameplay screenshots. Rather than add a separate vision model, I chose structured JSON as a common interface for the experiments.
The question was whether a model could make useful gameplay decisions, without also asking it to infer every collision box from a tiny image. Since I controlled the engine, I could expose the current scene directly.
An abbreviated example from a real request looked like this:
{
"decisionTicks": 4,
"scene": {
"elapsedTicks": 17,
"player": {
"x": 160,
"y": 174,
"health": 39,
"dives": 3,
"diving": false
},
"enemies": [
{
"id": 1,
"kind": "supply-pod",
"bounds": { "x": 17, "y": 65, "w": 14, "h": 14 },
"velocity": null
}
]
}
}
The full packet included visible enemies, projectiles, released pickups, terrain,
camera movement, health, weapons, upgrades and ability timers. Stable object
IDs and changes between observations supplied measured motion. An unknown
velocity was null, not zero: “I haven’t measured it” is not the same as
“it isn’t moving”.
The context eventually included two compact previous scenes and twelve recent action outcomes. What the ship actually did mattered more than what the model had intended it to do.
There were also advisory collision forecasts and terrain-clearance samples. These helped describe the consequences of candidate movements, but did not automatically dodge, filter out dangerous legal controls or steer the ship.
The model didn’t receive future enemy spawns, hidden movement scripts or the random-number state. This was still a much more precise interface than a human gets from pixels, though. It was a structured-state control experiment, not a claim about an AI understanding the screen.
Local inference sounded ideal
My first thought was to use Foundry Local. Local inference might avoid network latency and make repeated experiments cheap.
There was a small plumbing problem first: the game ran in Windows Subsystem
for Linux (WSL), while Foundry Local ran on Windows. Calling Windows curl.exe
from WSL reached the service’s Windows loopback endpoint, without opening
firewall ports or changing its network binding.
Connectivity worked. Competent flying was another matter.
With Qwen 2.5 1.5B on the neural processing unit (NPU), one 50-decision run returned valid JSON throughout, but every decision just held fire. A later prompt encouraged movement so successfully that another run went right on every decision and stayed at the edge. On small mirrored danger probes, it sometimes steered towards the threat.
Phi-3 Mini also struggled. One trial had a median inference time of roughly ten seconds for each four-tick action. A later response requested up and down simultaneously. The controller rejected it rather than inventing a replacement action.
We also tried the cached NPU variant of DeepSeek R1 Distill Qwen 14B. Its gameplay request timed out after 180 seconds without a response; a minimal follow-up probe failed too. We didn’t establish the root cause, so I wouldn’t turn that into a diagnosis of the model or the runtime.
Foundry Local had served models successfully. The combination of models, hardware, context and instructions I tested did not produce a useful player. That’s a failed experiment, not a conclusion that local inference cannot work.
Decisions, rather than paragraphs
Next I switched to Microsoft Decision 1.1, which I’d previously tried in a rather less demanding Magic 8 Ball.
This fitted the problem neatly. The model didn’t need to write a description of its flying technique. It needed to select an action.
The application supplied the state, a typed choice question, and named options
such as left_fire. That choice mapped to actual buttons:
{"input":{"left":true,"fire":true}}
There were movement, fire, coast, dive and surface combinations. The application defined the legal vocabulary, including whether another dive was available. The model selected within it. A valid choice could still be a terrible idea, but malformed prose was no longer the main integration problem.
The first short run was promising: 30 decisions, several different steering combinations, and two speed boosts collected.
It was also cheap enough to experiment with. Using the November 2026 Global Standard rate of $0.042 per million input tokens, with output tokens free, the recorded usage works out like this:
| Experiment | Requests | Input tokens | Median response time | Estimated cost (USD) |
|---|---|---|---|---|
| Early smoke test | 30 | 93,331 | 174 ms | $0.0039 |
| Later fresh-memory attempt | 396 | 5,338,752 | 433 ms | $0.224 |
Less than half a US cent for the smoke test, and about 22 cents for the larger attempt. The latter is the fresh-start run described below: roughly 90.6 seconds of game time across all three lives, reaching 22.16% of the level. That is the cost of a failed attempt, not a price tag for clearing the level.
Those response times were measured around the API calls, including the network round trip. The game was still paused while waiting for each reply. Instructions, action criteria, scene history and memories all count as input; the later run had a much larger context than the first test.
These are rate-based estimates, not an Azure invoice. They exclude the other experiments and coding-agent costs. Data Zone rates differ, and prices can change.
Then we started refining what “play well” meant:
- Preserve health.
- Open supply pods safely and collect the released upgrades.
- Collect credit bubbles for the shop.
- Shoot ordinary enemies.
The distinction between a sealed pod and a released pickup was particularly important. Ramming a pod opens it, but costs energy. This is not a clever collection strategy when the ship has a gun.
We encouraged firing while moving safely, choosing a consistent supply target, and moving conservatively rather than changing direction for no useful reason. Conservative did not mean stationary; it meant purposeful.
Making dive availability explicit also removed ambiguity. The prompt repeated the charges and current dive state, while the legal options prevented starting a new dive with no charges remaining.
Surviving is not the same as getting anywhere
At first, survival time seemed like a sensible benchmark.
It is certainly better than immediately dying. Unfortunately, it is possible to remain alive without making useful progress.

One fresh-start test reached 43.62% of the first map and was still alive when its decision budget ended, after 351.52 game seconds. For the last 232.66 seconds, it made no new forward progress.
The ship was repeatedly cycling against terrain. It had not solved the level. It had found a very time-consuming way not to finish it.
That pushed the benchmark towards furthest level progress, with health and other outcomes retained as diagnostics. We tracked new world-space progress, not just movement on screen or the forward half of a repeated back-and-forth loop.
Warnings alone weren’t enough. Telling the model “you are stuck” didn’t reliably produce an escape. The observation needed to explain why an apparently reasonable command wasn’t working.
For example, at the bottom of the screen, DOWN can request reverse scrolling. Holding down-and-sideways isn’t necessarily moving down-and-sideways through the world. The model needed the native recovery state, recent actual displacement and a longer-lived navigation goal.
We added visible-grid waypoint proposals that could persist across decisions. They were advice, not an autopilot: the model still chose the buttons.
Remember where it hurt
The decision model wasn’t learning as it played. Its weights stayed the same, and experience from one API call wasn’t automatically retained for the next. The improvements so far had come from a human-and-agent feedback loop: the coding agent and I reviewed failures and adjusted the instructions and context we gave the player.
A human player would start to recognise the level. “This is the narrow passage where I lost most of my energy last time.” The scenery triggers the memory, and you prepare for the danger before it happens again.
We wanted to reproduce that effect outside the model. Detect where the ship lost energy, associate the experience with that part of the level map, and bring it back into the decision context as the ship approached the same place. The hope was that several attempts would build up useful experience: not a retrained model, but the same model making better-informed decisions.
The memory system was deliberately small.
When the ship lost health, got stuck, or missed a released supply, we recorded an incident with its stage, horizontal position, world-space height and tick range. World height used the camera position as well as the ship’s on-screen position, so a warning referred to a place in the level, not just a screen row.
On a later attempt, nearby incidents appeared as warnings before the ship reached them. The journal was bounded to 32 incidents, with at most four nearby entries included in a decision.
Not every memory meant “avoid this”.
A missed supply was an opportunity: next time, get into position to shoot the pod and intercept the drop safely. We only recorded a miss when a previously visible supply actually expired uncollected in the native engine. Something disappearing from the observation wasn’t enough; it might have been collected.
This gave us a practical improvement loop:
Play a passage
-> Observe damage, a stall or a missed supply
-> Save the incident
-> Rewind to a recent recorded checkpoint
-> Ask the model to try again with that memory
-> Measure the result
We added rewinding to make building those memories faster and cheaper. Restarting from the beginning after every mistake would mean paying for fresh model decisions through sections we had already played, just to reach the same difficult encounter.
Instead, we replayed the recorded native controls to a checkpoint before the incident, without spending inference on that prefix again. New model calls could then focus on retrying the problem area with the memory we had just created. It was a shortcut for the improvement cycle, not an unassisted playthrough or a change to the game’s lives, health or difficulty.
There were useful local improvements. In one pre-emptive memory-and-waypoint trial, a resumed passage reached 53.52% rather than 43.62% after the same 640 native ticks. It spent zero ticks in native terrain recovery, versus 223 in the stalled baseline.
That was evidence of a better passage through that particular problem, not proof that adding memory universally improved the player.
An agent improving another agent
There were really two AI roles here.
Decision 1.1 was the player. A coding agent supervised the experiment: examining recordings, changing instructions or observations, adding checks, running bounded trials and comparing results. I directed the objectives and challenged the interpretation.
That was especially useful when the problem wasn’t simply a poor decision.
The first boss could be visibly entering the screen before its native collision box became active. Our JSON observation had used the collision box to decide whether to include it. The model could therefore be approaching a boss that a human could already see, without being told it was there.
We fixed the observation to include the visible boss, distinguishing its drawn body, active contact bounds and current weak point.
Another issue appeared when we shortened decisions for finer boss control. The collision lookahead had been tied to the decision interval; reducing that interval also removed advance warning. Keeping a minimum lookahead preserved time to begin an escape.
These are good examples of why “improve the prompt” can be the wrong diagnosis. Sometimes the model needs better information, or the surrounding control system needs fixing.
You could call the overall process recursive self-improvement (RSI), but only in a bounded engineering sense. An agent helped improve the instructions, memory and tools used by another agent, then tested the changes against an external result.
No model weights were updated. This wasn’t reinforcement learning or a model magically teaching itself a general solution. Some candidate instructions performed worse and were rejected. Some memory retries still failed.
The important thing was to give the supervising agent a meaningful objective to “hill climb” and some ideas to try.
It did beat the boss. There is a qualification.
Eventually, a checkpoint-trained trajectory defeated the stage-one boss.

This was verified in the engine: the boss was dead, its health was zero, and
the native end-level shop was opening with nextStage: 2.
That distinction mattered. 100% scrolling-map progress isn’t a level clear. The boss still has to be defeated.
The successful trajectory finished with 35 health on its third native life, without spending a continue. It included checkpoint rewinds and learned retries; the final retry replayed 2,089 earlier decisions before making 269 new, one-tick decisions. All 7,467 PNG frames were checked against native replay.
The obvious next test was to start again at tick zero with the learned memory. Normal health, normal weapons, three lives, no replayed actions.
It failed.
That run loaded 32 prior incidents, lost its first life at 14.84%, and peaked at 22.16% across all three lives. No continues were spent.
So the accurate result was a verified, checkpoint-trained stage clear, not a reliable fresh-game player. The memory was actually supplied to the model; delivery wasn’t the same as successful generalisation.
That was disappointing, and considerably more informative than stopping at the best-looking video.
However, Xenon 2 is a hard game. I think the AI player performed at a higher level than a novice and, in some cases, demonstrated very impressive bullet-dodging.
Then I stopped pausing the clock
The paused experiments answered whether the model could choose actions with time to think. I also wanted to try the original idea: let the game keep ticking while the model decides.
The real-time controller held the previous movement and fire buttons until the next valid response arrived. Dive remained a single press, there was only one request in flight, and responses from an obsolete game context were discarded.
These were fresh-start, first-life experiments, with no imported memories or rewinds. Both used the same settings.
| Measurement | First run | Repeat |
|---|---|---|
| Survival | 18.23 seconds | 18.45 seconds |
| Furthest level progress | 5.23% | 3.80% |
| Median response time | 433 ms | 461 ms |
| Slowest applied response | 829 ms | 5.78 seconds |
The simulation itself kept up: the repeat’s 18.45 game seconds took 18.46 wall-clock seconds. This wasn’t the engine failing to run in real time.

In the first run, decisions typically arrived eight native ticks after their observation. In the repeat, one response arrived with a scene 106 ticks old. The ship had kept following its previous controls while the call took nearly six seconds.
For a task router, half a second might be acceptable. For a small spaceship next to a hostile tentacle, it is quite a long time.
Real-time play failed in this configuration. Two runs don’t establish how much of the failure came from latency rather than policy, and they certainly don’t prove that decision models cannot control games. They do show why the smooth paused-mode replay wasn’t enough.
There is an application-modernisation story in here
Underneath the rather silly test application are some useful patterns.
Treat existing behaviour as evidence. A legacy executable can supply test cases and expected results even when its source is missing. In a less explosive application, differential tests might compare business calculations, file formats or state transitions before and after a migration. Tests are stronger evidence than an AI-generated explanation of what the old code probably meant.
Separate the engine from its interface. Extracting a headless core made the game easier to test, replay and control. The equivalent in a business application is domain logic that doesn’t require a browser session to run. Decoupling the clock made failures reproducible and experiments cheap.
A decision model doesn’t need to be a chatbot. Choosing a bounded next action is a useful building block: route this ticket, select this tool, escalate this case. The surrounding application should define legal actions, validate results and enforce resource limits. A finite answer vocabulary doesn’t make the judgement correct.
Memory can be small, factual and contextual. A bounded journal of “this happened here” was more useful than endlessly extending a chat transcript. The broader equivalent might be a known failure condition, a previously unsuccessful workaround or an opportunity that should be reconsidered. Such memories need provenance, relevance checks and an expiry policy; a past mistake isn’t a universal rule.
Agent-supervised learning needs an honest scoreboard. The interesting RSI pattern was a supervising agent inspecting failures and proposing measurable changes, not removing humans or rewriting model weights. A production version would need fixed evaluation criteria, held-out cases, bounded permissions, rollback and human approval where consequences matter. Checkpoint training and fresh-start evaluation should not be quietly mixed.
Latency is part of correctness. A decision can be sensible for the state it saw and wrong by the time it is applied. Measure end-to-end delay, tail latency and the age of the observation, not just average model speed. A production controller might need expiry budgets, a deterministic fallback or a slower high-level AI planner above a fast local control loop. Those are possible next experiments, not features demonstrated by this one.
What’s next?
There are a few experiments I’d like to try before declaring the tentacles victorious.
Give it eyes. I’d like to try a vision model with screenshots rather than the JSON scene. A short sequence of frames would give it a chance to estimate movement, rather than guess from a single image. I’d start with the clock paused, using the same seeds, legal actions and decision budgets as the structured-state tests. Can it work out where the gaps and threats are without being handed their bounding boxes?
Separate planning from reactions. An LLM could maintain a longer-term plan: get through this corridor, approach that supply pod from below, then move into position for the next passage. A decision model could choose the immediate buttons within that plan. The planner would reconsider when the goal was reached, the ship got stuck or something important changed, rather than on every decision. It would be plotting a course from what the player had seen, not reading ahead in the level files. That doesn’t remove latency: genuine real-time play might still need a fast local controller for immediate reactions.
Try other games. Pong or Breakout would give us a simpler scene for testing visual tracking, motion prediction and response delay, although they still require quick reactions. A turn-based puzzle such as Sokoban would test planning without the clock being the main opponent. That would help separate “can it work out what to do?” from “can it do it before the spaceship explodes?”
Find out which memories actually help. The fresh-start failure is a good reason to test this properly. Freeze the instructions and compare otherwise matched runs with no memory, incident warnings, and warnings plus waypoints. Evaluate complete fresh attempts, including seeds not used while tuning, rather than just the passages we rewound until they worked. It would be useful to know whether memories improve results, distract the model or simply add tokens.
Use the recordings to teach a smaller local player. Curated successful passages could become demonstrations for training a compact local controller. Unlike the incident journal, that would involve changing a model’s weights. It might offer a different route to local inference: use a larger model and the supervising agent to help produce examples, then test whether a smaller policy can reproduce the useful behaviour without the network round trip.
Conclusion
I started by asking whether AI could help recover a game from an old binary. It helped build the port, the reference tests, the headless harness and another AI’s practice environment.
The player even beat the first boss, given enough checkpoint practice.
Would I let it fly my spaceship in real time?
Not while the tentacles are moving.