ALife: CoreWar

May 14th, 2013

CoreWar is/was a simulation (also a game (though a very unusual one) and a competition) where programs written in an assembly-like language called Redcode competed against each other in a battle for survival within the virtual medium that was the core. It was quite popular during the nineties and we had many leagues, challenges and tournaments. Many great programs/warriors/artificial life forms were created at that time, either entirely manually or via some form of genetic programming and evolutionary computation. Here is a screenshot from the CoreWin simulator of one program duel:

Not many people know this, but I used to practice biology before I decided that I was going to study mathematics and computer science instead. Therefore, biologically inspired computational models still inspire me and I always enjoy working on their development.

As for CoreWar, it was my main preoccupation during my undergraduate studies back between 2003 and 2008. I’ve spent countless hours looking at the long lines of assembly code, dreaming up new attack modes, making the code more resilient to random mutations, playing with the placement of individual variables and optimizing everything one could possibly optimize. It was the most engaging experience of my youth and I have no regrets. True, it was entirely non-commercial, an art in its own right – but not everything is about the money. Artificial life research offers us valuable insights into the workings of life itself, enables us to run experiments at a pace that far exceeds the speed of actual species/population/ecosystem evolution in real environments and simulate our models and test our hypotheses. And it is fun, of course :).

After I’ve slowly climbed my way up the competitive ladder, I’ve become a sort of a Redcode-guru myself and I am proud to say that I have produced some of the most resilient CoreWar programs of all time. Below is an up-to-date screenshot from the 94nop (the standard parameter setup) ‘infinite hill’ called Koenigstuhl, where all the best warriors ever submitted (993) were pitted against each other in order to produce the final ranking.

As can be seen, I do have a competitive mindset. Though we have also all collaborated on projects very often and shared ideas over the CoreWar IRC channel (yes, that was the information pipeline of the time). It was a very pleasant community of people and the long discussions we’ve had still bring up some very nice memories.

During that time, we even had a small beginner magazine called Core Explorer going and here is what it looked like: issue1, issue2, issue3. However, as the years went by, the interest in the simulation slowly decreased, mostly due to the fact that assembly programming has grown out of fashion and the entire simulation had a sort of a “retro” feel to it, so it wasn’t attracting many new participants. Additionally, it was very challenging and difficult to get into, and would become a skill that can’t be directly monetized. However, this sort of reminds me of chess (as you might have guessed, another passion of mine). Both are complex mental challenges and require long term focus and dedication. Also, unless you’re a world-famous grandmaster, chess is probably going to end up costing you more money that what you would ever earn from it. Yet, it helps in keeping the brain sharp and provides a sanctuary from all the daily stress and pressure. Once you’re fully engaged, you’re “in the zone”, thinking in black and white and your world consists of 64 squares. Once the game is finished, normal life can resume.

For my graduation thesis, I’ve implemented a series of stochastic optimization methods for optimizing the parameters in manually coded CoreWar programs: genetic algorithms, simulated annealing, probabilistic leap hill-climbing and predator-prey particle swarm optimization. The optimization had multiple stages, as a single mutation can entirely ruin the program structure and purpose – and some parameter values were simply very weak. The program utilized a quick testing approach to prune out the weak parameter mutations and then proceeded to the second step. The second step involved a medium-sized benchmark of opponents from different strategies. This was an intermediate step, also speeding up things a bit, as only the parameter deltas that yielded improvements here were forwarded onto a final deep analytic step with an extensive opposition benchmark and a full strategic opposition spectrum. The details can still be found in my graduation thesis (see the link below).

Building a CoreWar Optimizer

After I came here to the Artificial Intelligence Laboratory, I have committed my time and energy to working on machine learning and data mining problems instead. However, I had my last streak of CoreWar before I came by working on several data mining application on top of the CoreWar data itself. We built a system that was able to predict the “species” of the artificial organism by analyzing its code or by looking at its performance against a predefined test benchmark.

Categorizing CoreWar Warriors
Categorizing Evolved CoreWar Warriors Using EM and Attribute Evaluation
Automatic Categorization of Human-coded and Evolved CoreWar Warriors
Optimization as a Step in CoreWar Program Analysis, Evolution and Categorization

My last genuine hands-on contact with CoreWar was a few years back, while I was a project leader at the S3++ Summer School of Science in Višnjan, Croatia – where I’ve led a two-week course titled Evolution in the Core – a Journey Through the Basics of Artificial Life. We have used the genetic programming techniques to automatically evolve a series of CoreWar programs. Improvements over the generations were visible. I was very happy with the outcome of the project, as I could see that the participants have enjoyed it and have brought home a valuable new experience.

Summing things up, I am still quite interested in working on ALife projects and would like to use my newly acquired data mining and machine learning skills for gaining a deeper understanding of the underlying evolutionary processes and complex system interactions. If you happen to be working on something like this at the moment, feel free to contact me and we could brainstorm some ideas.

For a list of resources on CoreWar itself, you could look at:
John Metcalf’s CoreWar page, Christian Schmid’t CoreWar page, the old KOTH server, SAL hills, Corewars.org and the Beginner’s guide to Redcode

Comments are closed.