

Two Programs Enter, One Program Leaves - gnosis
http://www.codinghorror.com/blog/2008/04/core-war-two-programs-enter-one-program-leaves.html

======
raphar
I would like to share with you a funny story about Corewar:

5 or 6 years ago, a group of students at the local university organized a
Corewar contest. The group of organizers were, how to say it, "theorethical
nerds", some of them in their way to be professors (two of them are in fact
professors today). Big egos too.

I was no more a student at the time so I didn't join the contest, but I
commented about it to my girlfriend because I had read about Corewar before
and found it interesting. My girl was a student and she liked so much what I
told her, that she decided to compete herself.

I can say that when she is obsessed with something, as she got with the
contest, she doesn´t stops at anything. So in less than a couple of weeks she
had serveral 'strains' of working bots each with different behaviours and
abilities. Until the last minute she was testing which were her bests programs
to compete.

So, the day arrived, and the more or less 10 MALE ppl at the competition saw
my girl, coming with no one but 3 (or 4) programs. I wish I could have been at
the event because my girl beat them all and with all of her bots. They even
disqualified one of her bots because it almost always tied (was a replicator)

I don't think they learned not to underestimate a confident blonde girl, but
the contest was conveniently forgotten and Corewar was never mentioned again
at the place :D.

------
jrbedard
Microsoft did something similar to promote the .NET framework in it's early
days. They launched the Terrarium competition
<http://terrarium2.codeplex.com/> where you would code your creature's AI in
C# or Managed C++ and ship it as a DLL that would compete against other
peoples creatures.

~~~
famousactress
Woah. Blast from the past. I remember that from the .NET launch. I still think
it's a really awesome initiative, and this sort of thing would be great for
getting high school kids interested in programming.

~~~
qeorge
They've got one for Azure now, I haven't checked it out though:

<http://www.rockpaperazure.com/>

------
rhettg
Back in the day I tried applying genetic algorithms to corewars as a high
school science fair project.

I lost. They had no idea what was talking about. Early lesson in the
importants of communicating technical ideas.

~~~
delinka
Oh, you lost the _science fair_. How did your code perform in battle?

~~~
rhettg
The evolved warriors weren't all that impressive either.

Really required a large number of generations, which my poor turbo pascal
skills or lack of hardware didn't really provide. I wonder if I can find that
code on a floppy somewhere...

------
biot
I'm reminded of a story I read a while back (around 20 years ago) about
engineers pointing out a security flaw in a vendor's Unix system, which the
vendor did not take seriously. So they wrote a pair of programs: Falstaff and
Othello, if I remember correctly... where if you killed one, the other would
output to the console something to the effect of "I'll save you!" and would
resurrect the other program, making it extremely difficult to eradicate from
the system.

I've been trying to find this... anyone have a reference to the original?

~~~
robinhouston
That sounds like a story that is recounted in the Jargon File
(<http://www.catb.org/jargon/html/meaning-of-hack.html>).

I wonder if it's a bit apocryphal. I feel sure I've also read a version where
the two processes were called “sheriff” and “deputy”, and you suggested yet a
third naming scheme.

“Back in the mid-1970s, several of the system support staff at Motorola
discovered a relatively simple way to crack system security on the Xerox CP-V
timesharing system. Through a simple programming strategy, it was possible for
a user program to trick the system into running a portion of the program in
‘master mode’ (supervisor state), in which memory protection does not apply.

[…]

Months passed. The Motorola guys pestered their Xerox field-support rep, to no
avail. Finally they decided to take direct action, to demonstrate to Xerox
management just how easily the system could be cracked and just how thoroughly
the security safeguards could be subverted.

They dug around in the operating-system listings and devised a thoroughly
devilish set of patches. These patches were then incorporated into a pair of
programs called ‘Robin Hood’ and ‘Friar Tuck’. Robin Hood and Friar Tuck were
designed to run as ‘ghost jobs’ (daemons, in Unix terminology); they would use
the existing loophole to subvert system security, install the necessary
patches, and then keep an eye on one another's statuses in order to keep the
system operator (in effect, the superuser) from aborting them.

One fine day, the system operator on the main CP-V software development system
in El Segundo was surprised by a number of unusual phenomena. […] Naturally,
the operator called in the operating-system developers. They found the bandit
ghost jobs running, and killed them... and were once again surprised. When
Robin Hood was gunned, the following sequence of events took place:

!X id1 id1: Friar Tuck... I am under attack! Pray save me! id1: Off (aborted)
id2: Fear not, friend Robin! I shall rout the Sheriff of Nottingham's men!

id1: Thank you, my good fellow!

Each ghost-job would detect the fact that the other had been killed, and would
start a new copy of the recently slain program within a few milliseconds. The
only way to kill both ghosts was to kill them simultaneously (very difficult)
or to deliberately crash the system.”

~~~
biot
Thank you... that is the one. I may have misremembered the characters involved
or perhaps read it from a different source.

------
arethuza
After watching that animation for a bit I can't help contemplating some
combination of Core War and Minecraft.... :-)

~~~
rhettg
Bomb SSSS #0

~~~
arethuza
You are going to have to explain that one...

~~~
fdb
He's referring to the sound a creeper (Minecraft enemy) makes right before it
blows up.

------
sylvinus
I couldn't find a Javascript environment for running this. Anybody knows if it
exists?

If not, who's up for a github night ? ;-)

~~~
Tichy
I've been thinking about creating one, having been an active Corewars player
back in the day.

A problem could be compatibility with the pmars parser, which has been the
standard for a long time. I tried writing a parser for corewars years ago and
run into trouble emulating some aspects of the pmars parser.

~~~
sylvinus
yep I'm currently wrestling with it. I've a prototype that precompiles EQU and
FOR/ROF and I'll try uploading it to github when it's a bit more tested.

~~~
Tichy
Even a JS Corewars interpreter that can only compile "assembly" would be nice
to have. Then people could compile their warriors with pmars and put fancy
simulations on their web sites. Not saying that it is impossible to clone the
pmars compiler, but it is a mess :-)

~~~
sylvinus
I've got the precompiler working quite well. Interestingly, it translates the
redcode/pMARS code line-to-line to Javascript which is then executed to
produce the assembly.

redcode is indeed a mess, clearly the result of an evolving and blurry
standard :)

anyway, I'm spitting out assembly for 90% of the bots I've tried and have the
Imp running. From now on it will indeed be a job of implementing each
instructions and addressing modes. I'm definitely uploading this on github in
a few hours and will be very happy to have some help ! :)

------
nuclear_eclipse
In university, we did something vaguely similar for class projects using
Robocode: <http://robocode.sourceforge.net/>

~~~
jacques_chester
Which was inspired by Robot Battle on Windows, which was inspired by Robot
Wars on the Apple ][.

~~~
mkramlich
I played Robot Wars on the Apple ][. And Rocky's Boots and A Robot Odyssey.
Awesome games for hacker/maker personalities. And yes, I'll be on my rocker.

------
alex_h
What happens if the instruction pointer for, say, process A, steps into the
code space for another process, B? Does the simulator treat it as an illegal
instruction causing A to lose? Or does process A continue, but executing B's
code?

~~~
kenjackson
I think it treats it as a legal instruction.

What I don't get is the replicator strategy. How does replicating yourself
help not die? Even if you replicate yourself to all the memory except one
address -- but that one address is where your IP is you're screwed. It seems
like repairing yourself and attacking the opponent are the only feasible
strategies -- at least if I understand correctly.

~~~
elwin
Replicators split into multiple processes, each with its own IP. A program
isn't considered dead until all its processes are killed. If one of its
processes stumbles across a bad address, the others aren't affected.

~~~
kenjackson
Ah OK, didn't read carefully enough. Thanks.

------
aerique
Ah, good old Core Wars!

It is perhaps interesting to know that the next installment of the Google AI
Challenge (<http://ai-contest.com>) is a couple of weeks away and it allows a
wide range of programming languages.

------
conflagration
The nice thing about them is that they are very short and so you can try a lot
of different strategies, but there were also long scripts like Mule DNA. I
think this is a great way to teach kids the basics of addressing and low level
programming. I remember writing these bots for a friends computer science
class, good times.

------
lycos1
This looks like a fun alternative to the typical weekend hackathon. I'll give
it a whirl.

