Two Programs Enter, One Program Leaves
codinghorror.com
codinghorror.com
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.
I lost. They had no idea what was talking about. Early lesson in the importants of communicating technical ideas.
Guys from the IEEE talked to me at length, loved it, and gave me their grand prize. Two judges (both Lisp hackers (and both thrilled to see an 18-year old doing AI with CL)) also loved it...but the other judges did not understand it at all, so I didn't even place at the actual fair. Sigh.
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...
I've been trying to find this... anyone have a reference to the original?
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.”
If not, who's up for a github night ? ;-)
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.
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 ! :)
https://github.com/joshfire/corewarjs
I've got imps and a few other running :)
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.
The most basic imp is defined as
mov 0 1
It copies itself to one instruction ahead of itself. On the off chance it hits the opponents pointer, the opponent becomes an imp too and they both just circle around the core forever.See elwin's comment below on vampires (for now, hopefully above soon).
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.