Welcome to the CoreWars Evolver home page.
Copyright © 2005-2013, Miha Vitorovic
All the GA related options and instructions are part of the version 0.5 and currently not available, unless you
checkout the source and build the application yourself. But even then some things still don't work.
Index
1. Introduction
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.
2. User information
2.1. Instructions
To run CoreWars you will need Java 6.
You may download it from www.java.com.
After you install Java, you may start CoreWars with:
java -jar <JAR archive name> [options]
warriorFile [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
GA options:
-GC $
(--generate-config) Generates config XML file with a given name.
-RC $
(--run-config) Runs the GA algorithm using the config file.
2.2. Documentation
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.
It supports all ICWS'94 OpCodes including P-space, and so far the following meta instructions:
- org <start address>
- end [<start address>]
- ;assert <expression>
- ;name
- others will be added later
- labels and address arithmetics - parentheses may be used to change priority
- operators & priority:
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
! not
Assignment (will be added
later)
= assignment
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.q. you may get '7983' instead
of '-17', for CORESIZE 8000.
2.2.1. Genetic algorithm
Please note, that fitness function should evaluate to floating point number.
For GA fitness function the following operators may be used:
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
! not
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) ||
Variables are the statistics collected during the warrior execution, and can be used to
calculate a fitness function. This section lists variables and gives some examples
on how to used them
- size - the initial size of the warrior
- cycles - the number of cycles the warrior ran
- With randomly generated warriors, for the first "couple" of generations one of the few things worth testing is, how
long can the warrior run at all
- warrior starts on a DAT command; score -500:
(cycles<1)*(-500)
- warrior runs for less than 10% of it's size and then dies; score -100:
((cycles*1.0/size)<0.1)*(-100)
- warrior runs for 10%-40% of it's size; score 100:
(((cycles*1.0/size)>=0.1)&&((cycles*1.0/size)<0.4))*100
- warrior runs goes through a major part of it's instructions; score 300:
(((cycles*1.0/size)>=0.4)&&((cycles*1.0/size)<1.0))*300
- warrior actually contains a loop; score 1000:
((cycles*1.0/size)>1.0)*1000
- A fitness function covering all of the above cases would just have to add all these equations
- id - the ID (number) if the current warrior. Nonzero number.