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:
- 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.
- 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.
- 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:
12345678require "mars"mars = Mars.standard(2) # standard mars settings, two warriors.w1 = mars.parse("warriors/94nop/behemot.red")w2 = mars.parse("warriors/94nop/reepicheep.red")mars.rounds = 200puts m.fight(w1, w2).results_str
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).