|
|
 |
 |
|
 |
 |
 |
"exMARS combines the latest advance in corewar simulation
technology, with proactive performance optimizations."
I always wanted to try myself as a marketing slogan writer
.
Actually exMARS is a redcode simulator, just like exhaust and pMARS.
In fact, I have shamelessly taken sourcecode from pMARS, exhaust, some
ideas from qMars, a shot of optimizations, shook everything well, and
garnished everything with a high level interface for
Ruby.
The resulting program has the following main features:
- Uses the parser from pMARS, so no previous parsing is neccessary.
At first this was my main motivation for exMARS.
- Speed: 50% faster than pmars on a pentiumIII, and often more than
twice as fast than pmars pentium 4 (using
gcc 3.3.1, and the same
compiler options).
- Rewritten the code in a more object oriented way, which allows
different Mars at the same time in the same program, it should also
be thread safe.
- Ruby interface: finally
a really fast mars can be used in a high level programming language.
(see test.rb for an example usage)
At the moment exmars is probably an alpha version. It contains almost
all features I want it to have, but the programming interface will
definitely change.
I have only tried exMARS in Linux, because I do not have access to
windows right now, a simple 'make' would do. Have a look at the
Makefile for optimizations.
|
 |
 |
 |
|
 |
 |
 |
It seems to work pretty fine. The only thing left is a high quality user interface in C.
|
 |
 |
 |
|
 |
 |
 |
 |
|
 |
 |
 |
I try to make exMARS as simple to use as possible. This is the
interface I have in mind:
#include "exhaust.h"
mars_t* exmars_new(int warriorCount,
field_t coreSize,
u32_t cycles,
u32_t maxProcesses,
u32_t maxWarriorLen,
u32_t minWarriorDist);
mars_t* exmars_new_94nop(int warriorCount);
mars_t* exmars_new_tiny(int warrriorCount);
warrior_t* exmars_parse(mars_t* mars, char* inputFileName);
void exmars_simulate(mars_t* mars, warrior_t** warriorArray);
char* exmars_resultstr(warrior_t** warriorArray);
void exmars_set_score_formula(int (*scoreFormula)(int warriorCount, int survivorCount));
int exmars_last_score(mars_t* mars, warrior_t* warrior);
int exmars_total_score(mars_t* mars, warrior_t* warrior);
void exmars_free_mars(mars_t* mars);
void exmars_free_warrior(warrior_t* warrior);
u32_t exmars_get_rounds(mars_t* mars);
u32_t exmars_get_coresize(mars_t* mars);
u32_t exmars_get_cycles(mars_t* mars);
u32_t exmars_get_max_processes(mars_t* mars);
u32_t exmars_get_max_length(mars_t* mars);
u32_t exmars_get_min_distance(mars_t* mars);
u32_t exmars_get_warriors(mars_t* mars);
void exmars_set_rounds(mars_t* mars, u32_t newRounds);
void exmars_set_cycles(mars_t* mars, u32_t newCycles);
enum emars_opcode {
DAT, SPL, MOV, DJN, ADD,
JMZ, SUB, SEQ, SNE, SLT,
JMN, JMP, NOP, MUL, MODM,
DIV, LDP, STP,
EXMARS_OP_COUNT
};
enum exmars_modifier {
mF, mA, mB, mAB, mBA,
mX, mI,
EXMARS_MODIFIER_COUNT
};
enum exmars_addrmode {
DIRECT,
IMMEDIATE,
BINDIRECT,
BPREDEC,
BPOSTINC,
AINDIRECT,
APREDEC,
APOSTINC,
EXMARS_ADDRMODE_COUNT
};
typedef struct exmars_ins
{
enum exmars_opcode opcode;
enum exmars_modifier modifier;
enum exmars_addrmode addrmode_a;
long val_a;
enum exmars_addrmode addrmode_b;
long val_b;
} exmars_ins;
typedef struct exmars_warrior
{
u32_t length;
u32_t startOffset;
exmars_ins* code;
u32_t* lastWins;
u32_t lastLosses;
u32_t* totalWins;
u32_t totalLosses;
char* name;
char* version;
char* date;
char* fileName;
char* authorName;
} exmars_warrior;
|
 |
 |
|