Core Wars: The battle of the programmers.

Okay, brace yourself for a lengthy background story:

In the 1960's and 70's, computers were much too expensive for a normal person to have one all to themselves. Before the invention of the Personal Computer (PC), computer systems were mainly employed in large universities, able to be used by students. However, there came a danger with all this: Back then, there was no such thing as protected memory, meaning that someone with minor hacking skills and some knowledge of assembly could easily wreak havoc on other people's data and programs. One such urban legend is that of a major business firm's main computer system, which a mischievous employee had installed his own assembly program called creeper, who's only purpose was to create copies of itself whenever it was run. This soon became a problem, as the creeper virus began eating up precious space in the memory and began corrupting other people's data and programs. After a while, another more brightly-hatted programmer created a program called reaper, which would make numerous copies of itself and destroy any creeper virii it could find and then self-destruct. Soon enough, things were back to normal.

After hearing this story, a programmer named A.K. Dewdney got the idea for a game which he called "Core Wars". In this game, people would write computer programs called "warriors" in an assembly language called Redcode. Redcode had instructions not out of the ordinary of any assembly language. These programs were then run simultaneously in a simulated computer called MARS. The aim of the game was to make the opposing program crash by forcing it to execute an illegal command in the computer's shared memory. The surviving program was declared the winner. The absolute simplest warrior was called imp, and was written by Dewdney:

MOV 0, 1

The MOV command moves copies a command from one place to another, in a position relative to the MOV command. Because of this, the imp would fill up the entire memory with MOV commands in a relatively short amount of time. Because the memory loops around (So, if the size of the memory is 8000 commands, then command 8001 would be executed as command 0) then it meant imp would always hit it's target eventually if it wasn't hit first. Another program which was written by Dewdney is called Dwarf:

bomb      DAT 0,0
Dwarf     ADD #4,-1
                MOV bomb,@bomb
               JMP Dwarf
End Dwarf

This is the first example of a "bomber" program. This program would drop DAT 0,0 (An illegal command) at every fourth slot in the memory in the hopes that the other program would accidentally execute it (cookie if you can figure out how it works). There are far other types of examples, like scanners, which try to scan the commands around it to see if they are illegal. Some programs can even repair themselves mid-battle.

So, does anyone else still partake in this ancient game? I recently just got into it, writing my first warrior program a few days ago. Have no idea if it works, but it sounds pretty cool. It's based off of Dewdneys Dwarf but with a few modifications (I named it MindSplitter):

bomb      SPL 1
                JMP -1
                DAT 0,0
Split        ADD #5,-1
                MOV bomb,@bomb
               JMP Split
End Split

First off, this plants bombs at every fifth command instead of fourth, which I hope will help it spread out. Second, the bomb it uses is my personal invention that I call the Splitter bomb. In Redcode, the SPL command will jump execution to the specified command, while at the same time continue executing the commands after it. The idea is that the SPL will split to the jump command while the normal execution goes to the jump command, and both of them jump back to the SPL, therefore filling up all of the enemy programs processes. If the enemy program somehow manages to escape the loop, there is a deadly DAT after it. I haven't tried this out yet and I'm not sure how it would do in battle. If someone with a MARS emulator and a warrior of their own would like to put it to the test, I'd would absolutely love to hear how it turns out :).

Picture of Core Wars: The battle of the programmers.
RoderikB1 year ago

Call me a fossil, but I like to play around with corewars.

I'm afraid your program won't work as intended: The original Dwarf copies one instruction. Your program wants to copy three instructions. Your single MOV doesn't do that.

Some other observations:

- Corewar memory is circular, so after address 7999 comes 0 again, so you will overwrite yourself, how do you compensate for that?

- Putting SPL/JMP in the other's code will not kill your opponent, just make it spawn more and more processes. So, you won't acually win, just get a draw at best

If you want to play around, try ARES, (http://harald.ist.org/ares/) in integrated editor, debugger etc.

Have fun!