Developed and built using Netbeans 8
Mars interpreter (I hope) finally works correctly, or at least it runs the "validate.red" warrior (part of pMARS distribution) the way it should. It's not "lightning speed" fast, but I was more interested in the correct results as speed. I intend to optimize later.
Found a nice collection of warriors at http://cristal.inria.fr/~doligez/corewar/rc/
Done so far:
Arithmetic:
+ addition or unary plus
- subtraction or unary minus
* multiplication
/ division
% modulo (remainder of division) Works only on Integers!
Comparison:
== equality
!= inequality
< less than
> greater than
<= less than or equal
>= greater than or equal
Logical:
&& and
|| or
! unary negation
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) ||
CompiledWarrior: contains memory cells for compiled warrior, its id and name. This is temporary only, and is later copied into core.
passes pMars 'validate.red' ;)
package mars.mike5.debugger:
- a simple debugger interface, capable of opening multiple memory inspection windows, and
one window for each warrior. Marks selected memory location, or the next warrior
instruction. Also a P-space dump window for each warrior may be opened. It is possible
to edit core/P-space contents in place.
package mars.mike5.ga:
- this package contains all the GA stuff and the handling of the generations. Each generation can
be archived for analysis. The type of archive is folder or Zip. The contents of the archive are:
* MARS settings
* all the warriors that were used for this generation
* their scores
* all the warriors that are created through GA crossover and mutation
package mars.mike5.ga.eval:
- this package contains the code to evaluate GA fitness function. Each function evaluates to a real number (double) result. The mode for binary operations is the same as Java, i.e. if one of the operands is a real number, the result is a real number, otherwise it is an integer. The fitness evaluation supports scalar variables and 1-D array variables. These are always provided by the system and cannot be changed.
+ operators & priority:
Arithmetic:
+ addition or unary plus
- subtraction or unary minus
* multiplication
/ division
% modulo (remainder of division) Works only on Integers!
Comparison:
== equality
!= inequality
< less than
> greater than
<= less than or equal
>= greater than or equal
Logical:
&& and
|| or
! unary negation
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) ||
Still to do (order of preference):
All GA stuff:
- create configuration handling. Entire generation can be stuffed into a ZIP file.
- Action 'Break after this generation and dump all data to resume later'
- warrior fitness evaluation ('Original writer' and 'Last modifier' should be helpful)
- enable creation of entire state dump after each generation. Must allow resume:
+ Dump all warriors
+ Dump all necessary information, their score, survival rate, etc. into XML file
MemArray.java:
- make interpreter faster (maybe)
Debugger.java
- add 'Finish round' button
CoreWars.java
- add pMARS (and maybe KoTH) compatible output
- add other other ICWS language variants as well
Write great documentation and comment everything ;)
Version 0.5:
- Added CLI parameter -GC (--generate-config) which generates XML configuration for GA. The name/location
of the XML file is passed as a parameter. The configuration also includes any warrior files found in the same
folder as XML file.
Version 0.4:
* Added all pMars supported operators
- added ;assert
- multiple labels per instruction
- SPL honors the MAXPROCESSES setting
- Assignment and variables added
- Added P-space to warriors
- Added P-space inspection window to debugger
- LDP and STP implemented
- CLI option -S and hide P-space inspection in debugger when necessary
- debug option changed to '-e'
- addresses larger than 75% of CORESIZE are now displayed as negative in debugger
- load the first warrior at address 0
- Core/P-space editing in debugger
- Added CLI option -F
- Added CLI options -c and -p
- Debugger now dumps each warrior
- Added CLI options -b and -l
- Debugger assembly warrior dump flushes with every println
- pMARS compatible warrior assembly dump
- added inspect size spinner to Debugger window
- added support for multiline EQU (preprocessor)
- added support for FOR/ROF loops
- added CLI parameter -r
- added CLI parameter -=