|
 |
 |
QMars stands for Quicker Mars. It is a completely new
implementation of a mars simulator, which is an interpreter of the Assembler-like language RedCode, which is
used in CoreWars.
QMars is heavily optimized to be as fast as possible. Here are the main
advantages/disadvantages of QMars:
pros |
cons |
- completely written in C++
- simple interface
- fastest simulator on planet
- small executeable, low RAM-usage
- extensible: using Template
Metaprogramming techniques, the behaviour (output, debugging) of
the simulator can easily be modified
|
- slow compilation: with full optimization over 1 minute (on a AMD Duron 650).
- huge amount of RAM needed during compilation (with full optimization: 110MB)
- does not support LDP, STP (but should not be difficult to add)
- less tested than other simulators
|
IMHO QMars is a nice addition to other existing mars simulators. pmars has a lot of features and a nice user
interface, exhaust is a lightweight simulator written in C.
|
 |
 |
 |
|
 |
 |
 |
Latest release:
Previous release:
The source is under a BSDish licence. This is
not as restrictive as GPL (you can even sell this program, if you want...).
|
 |
 |
 |
|
 |
 |
 |
Both projects are compiled using g++ 2.95.3 and this command-line option -O9 -fomit-frame-pointer -fforce-mem -fforce-addr -finline-functions -funroll-loops -mcpu=i686 -march=i686.
pmars 0.9.2 QMars
Fixed vs Fixed 24.93 16.65 66.8%
Jaguar vs Fixed 29.16 18.92 64.9%
Jaguar vs Jaguar 43.21 27.47 63.6%
Stalker vs Fixed 24.84 17.56 70.7%
Stalker vs Jaguar 26.06 18.52 71.1%
Stalker vs Stalker 21.12 15.40 72.9%
nPaperII vs Fixed 35.46 23.18 65.4%
nPaperII vs Jaguar 44.55 30.14 67.7%
nPaperII vs Stalker 30.33 20.48 67.5%
nPaperII vs nPaperII 50.75 32.89 64.8%
-------------------------------------------------
Sum 330.28 221.21
100% 67.0%
As you can see, QMars takes only 67% of the time that pmars uses. pmars can do 10*2000/330.28 = 60.6 fights/seconds, QMars 90.4. This makes QMars (90.4-60.6)/60.6 = 49.2% faster than pmars :-)
|
 |
 |
 |
|
 |
 |
 |
QMars is very easy to use, which makes it a good choice for Evolvers. What follows is a perfectly workable code:
|
1 #include <iostream>
2 #include <vector>
3 #include "warrior.hpp"
4 #include "qmars.hpp"
5 #include "parser.hpp"
6 using namespace std;
7
8 int main(int argc, char* argv[])
9 {
10 const ulong cWarriors = 2;
11 const ulong cCoreSize = 8000;
12 const ulong cCycles = 80000;
13 const ulong cProcesses = 8000;
14 const ulong cWarriorDist = 100;
15 Parser p;
16
17 // create mars for redcode-standard. It should not output anything.
18 Mars<cWarriors, cCoreSize, cCycles, cProcesses, cWarriorDist, eSilent> m;
19 // create array of pointers warriors. The simulator will use this array
20 vector<Warrior*> warriors(2);
21
22 // create an Imp
23 Warrior* imp = new Warrior;
24 imp->code.push_back(Code(eMov, eI, eDir, 0, eDir, 1));
25
26 // parse a warrior (the parser needs the output of pmars)
27 warriors[0] = imp;
28 warriors[1] = p.parse("warriors/jaguar.rc", cCoreSize);
29
30 // simulate warriors with 1000 fights
31 m.simulate(warriors, 1000);
32
33 // print scores
34 cout << imp->win << " " << imp->tie << endl
35 << warriors[1]->win << " " << warriors[1]->tie << endl;
36 }
|
|
 |
 |
 |
|
 |
 |
 |
Copyright (c) 2001, 2002 Martin Ankerl
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by Martin Ankerl.
4. Neither the name of the author nor the names of any co-contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
|
 |
 |
 |
|
 |
 |
 |
First release of QMars. It is almost 50% faster than pmars on my system.
|
 |
|