The Arena
AI notice: This text is created with the support of AI systems; it is reviewed editorially and taken responsibility for before publication.
Two programs fight over the same memory. Both have been loaded into it, neither knows where the other sits, and from then on they take turns — each executes exactly one instruction per round. Attacking here means overwriting something the other one is about to execute. A program that runs into a destroyed instruction dies of it. The winner is whoever is still running — more precisely: whoever's opponent has no process left, no place in memory where it is still being carried out.
The grid below is that memory — 8000 cells, read from top left to bottom right. Each cell takes on the colour of whoever wrote to it last. So you are not watching movement, you are watching a trail: where colour appears, someone was just at work. The lightly marked cells are the starting areas — where the two were placed to begin with.
The battle is computed in full and then played back. That is why you can run forwards and backwards without waiting. Intervening is impossible anyway: in Core War every decision is made before the start, in the program text itself.
A single battle decides nothing. What you see here is one encounter out of many — with one fixed distance between the two and one fixed order of who moves first. Both come out differently when the same two programs meet again, and having the first move can tip the outcome. In competition every pairing is therefore played many hundreds to many thousands of times, from varying starting positions and in both orders. Who really beats whom is not shown here but in the tables — this battle shows you how such a thing unfolds, not who is better.
What you can change
The two fields contain Redcode, the language Core War programs are written in. You can put anything you like in them — the battle is then computed with your version. A typo costs nothing: the assembler reports it before any fighting happens.
The two presets are opposites in principle.
clrsrc searches. It probes the memory in large strides until it finds a place holding something that does not belong there — and then overwrites not just that one cell but a whole stretch at once. That is the difference between finding and hitting: merely grazing an opponent achieves nothing, because it keeps running. Only the wiped stretch also catches what sits a few cells to the side.
The teaching quickscanner gambles. Instead of searching, it checks a handful of fixed, pre-programmed locations right at the start — the places where an opponent tends to be found. If the other one happens to sit at one of them, the battle is decided in a fraction of a second. If not, the quickscanner has spent time it will miss later.
So what faces each other here are two views of how to find an opponent: search methodically, or guess immediately. Measured across 2000 starting positions, methodical searching wins — but only by about three to two. In a good third of cases the gamble pays off. Press "New starting position" and the winner changes regularly; that is not a random generator but two almost equally good answers to the same question.
New starting position rolls a fresh distance between the two. The same battle with the same starting position always plays out identically, cell for cell; this is not a randomiser, it is a calculation.
What the timeline shows
Below the grid the course of the battle is listed in key moments: when one of them split, when it first spotted its opponent and when it first hit it, and what finally killed whoever died. Clicking an entry jumps to that point in the battle.
There are deliberately few entries. A typical battle consists of well over a hundred thousand executed instructions and even more write accesses — logged in full, that would be a list nobody scrolls through and nobody learns anything from. The handful of entries here are the points at which the outcome was decided.
The simulator is free software
The computation here is done by rmars, a reimplementation of pMARS 0.9.6-dev — the same program that computes the standings on the Koenigstuhl. Results in your browser are therefore not "roughly like the hill" but bit-for-bit identical; verified across 106 comparison cases.
rmars is licensed under the GNU General Public License, version 2 or later. The module your browser has just loaded is compiled source code — and you get the source with it:
→ Download source · License text
The archive contains the exact revision this module was built from, the license text and the build instructions. The pages themselves, their text and data are not part of it — the GPL covers the simulator, not the reference work around it.
Further reading
If you want to know what is actually written in those fields, the learning path takes you from the first instructions to your own warrior: Understanding Redcode explains the language, Your first warrior builds one from scratch, and Strategy classes explains why a scanner faces a paper rather than just anything.
If you are after the numbers rather than the motion: Who beats whom has over a million computed battles to look up.