This page provides some information about the upcoming version 0.5. Version 0.5 is currently in the BETA stage and may still contain some bugs.
Java GA Redcode evolver v 0.5
Copyright (c) 2005-2014, Miha Vitorovič
The goal of this project is to develop a Java Genetic Algorithm redcode warrior evolver. This document provides some basic information and is split into two parts. It starts with the user part, followed by a developer part.
To run CoreWars you will need Java 8. You may download it from http://www.java.com . After you install Java, you may start CoreWars with:
java -jar <JAR archive name> [options] warriorFile [warriorFile ...]
Options:
-e (--debug) Opens debug window, allows single-stepping, and memory inspection.
-r # (--rounds) Specify the number of rounds.
-s # (--size) Specify core size.
-c # (--max-cycles) Sets the maximum number of cycles per round.
-p # (--max-processes) Sets the maximum number of processes a warrior can run.
The default is 8000.
-l # (--length) Sets the maximum length of a warrior source file in
instructions. It defaults to 100 and can be up to 500.
-d # (--min-distance) Specify minimal distance between warriors.
-S # (--p-space-size) Specify P-space size.
-F # (--fixed-address) Install second warrior at fixed address #.
-b (--brief) This options runs pMARS in brief output mode. It
suppresses warrior listings after assembly.
-= $ (--score-formula) Define a score formula. Default: (W*W-1)/S
-GC $ (--generate-config) Generates configuration XML file with a given name.
-RC $ (--run-config) Runs the GA algorithm using the configuration file.
Mars interpreter (I hope) finally works correctly, or at least it runs the "validate.red" warrior (part of pMARS distribution) the way it should. The interpreter is based on ICWS 94 Proposed Standard implementation http://www.koth.org/info/icws94.html
It supports all ICWS'94 OpCodes, and so far the following meta instructions:
Arithmetic:
+ addition or unary plus
- subtraction or unary minus
* multiplication
/ division
% modulo (remainder of division)
Comparison:
== equality
!= inequality
< less than
> greater than
<= less than or equal
>= greater than or equal
Logical:
&& and
|| or
! unary negation
Assignment:
= assignment to a variable
Comparison and logical operators return 1 for true and 0 for false.
Parentheses can be used to override this precedence order:
1) ! - + (unary)
2) * / %
3) - + (binary)
4) == != < > <= >=
5) &&
6) ||
7) =
Supports EQU and FOR/ROF loops. The goal was to compile everything pMARS does, and even some things that pMARS doesn't. The compiled output may not be character by character the same as with pMARS, but is functionally equivalent, e.g. you may get '7983' instead of '-17' for CORESIZE 8000.
Variables contain the statistics collected during the warrior execution as well as some MARS settings. They can be used to calculate a fitness function. This section lists variables and gives some examples on how to used them:
myOW - stands for "my original writers". Each memory cell holds two pieces of meta-information:
myLW - stands for "my last writer". This variable contains the last writers information for the last X executed commands of the current warrior. The last executed instruction is at index 0. Index 1 means the one before last executed command.
EXAMPLES: These variables help with better diagnosing the cause of the "death".
if(myOW[0]==id && myLW[0] == 0) --> The warrior died executing its own DAT statement; bad
if(myOW[0]==id && myLW[0] == id) --> The warrior died executing its own DAT statement, and it actually modified it before that. Maybe it wasn't a DAT statement before; REALLY BAD
if(myOW[0]==0 && myOW[1] == id) --> the warrior jumped to uninitialized core; bad
if(myLW[1] != id) --> the warrior died as a direct consequence of the other warrior's actions; not so bad
otherOW - stands for "other original writers". This variable contains the original writers information for the last X executed commands of the opponent. The last executed instruction is at index 0. Index 1 means, the one before last executed commands.
The variables otherOW and otherLW help with diagnosing the current warriors offensive abilities. It can tell whether the warrior won because of its offensive behavior or it simply outlived a suicidal opponent.