CoreWars Simulators Overview

I have just received a patch for qMars from Pavel Ĺ avara, so I have finally got some updated information about the different CoreWars simulators I have written. All of them have quite different properties, so have a look and choose whichever suites you best:

qMars

  • Download: qmars_1.1.tar.bz2
  • Speed: Pretty fast
  • Coolness: Very cool
  • Techniques: To achieve the speed, qMars uses a code generator that generates a very big switch-statement (383 cases) which allows for highly optimized code that would not be possible to write by hand. It is written in C++ and uses some template metaprogramming tricks which gives it a high coolness factor.

exhaust-ma

  • Download: exhaust-ma.zip
  • Speed: Pretty damn fast
  • Coolness: Cool enough
  • Techniques: This is a modified exhaust with some quite obscure optimization tricks. It achieves its speed through hand-optimized code for the most commonly used commands (MOV.I, DJN, SPL). It uses several bit operations and lots of macros which makes the it exceptinally fast and the source exceptionally unreadable. It is written in C, and compiles quite fast.

exMARS

  • Download: exmars-0.01.tar.gz
  • Speed: Pretty damn fast
  • Coolness: Extremely amazing Cool
  • Techniques exMARS combines the best parts of exhaus-ma with pmars and goes even further:
    • exMARS uses the parser of pmars which means that you can read in any warrior file, no need to preparse the warriors like in exhaust or qMars.
    • exMARS uses the simulator engine of exhaust-ma which means it is pretty damn fast.
    • exMARS contains several fixes to memory leaks of the pmars parser and the interface has been rewritten, so now you can embedd exMARS in your application and have multiple different mars simulators at once.
    • There is more, read this slowly to let it slowly sink in: exMARS has Ruby bindings. That means you can write an evolver in Ruby and still have an exceptionally fast simulator. Usage is like this:

    Told you it is cool.

On a side note, somebody has taken these ideas to the extreme and wrote fmars, which is the currently fastest corewars simulator on the planet, which rightfully deserves to be called “pretty amazing damn fast”. Unfortunately it can be a bit tricky to compile and only works with gcc. But he has also a Python interface (with SWIG, so generating Ruby, Java or whatever interface you like should be very simple).

4 Comments on "CoreWars Simulators Overview"

Notify of
avatar
exmars
Guest

I saw the newsgroup post and am intrigued by the Ruby interface. Any idea how difficult it might be to turn that into a Common Lisp interface?

(fmars doesn’t seem like a better choice, SWIG is sorta there, but I wouldn’t bet on anything else working at all).

martinus
Guest

I am not sure how difficult it is to make this work in Lisp. I think the difficult parts are all done (e.g. fixing the nasty memory leaks, restructuring the code to make it embeddable), if Lisp provides a relatively easy way to integrate C code, this should be quite straightforward. I have never used Lisp, so I dont really know.

Nick Brandaleone
Guest

Hi, where do I get the RUBY interface/gem?

wpDiscuz