Implementation

Robots for Real-time battle can be written in any language that can handle standard input and output streams, hence almost any language available. I decided to write the software in Java since I happened to be taking a class on it at the time.

The software for the evolution of genetic programs for Real-time battle consists of five programs.:

Parents.java, is used to generate a certain number of random programs that will be used as parents for generation zero. These programs are saved as text files in the parent directory.
<>
Mutator.java, takes all the parents in the parent directory and breeds them together to create the children. It saves the children in the robot directory and copies the parents into the same directory so that they can be part of the battle too. The number of children is equal to the number of parents squared.

Generator.java is then used to create the shell scripts needed by Real-time battle to execute Java programs. The reason for this is that Real-time battle can’t send command line arguments to the robots so these have to be sent through a shell script instead, one script is generated for every child.

Geneticbot.java is the main program that loads the genetic program, executes it and handles the communication with Real-time battle.

Evaluator.java takes the statistic file created by Real-time battle after each tournament and evaluates the fitness of the genetic programs. The fitness function was originally just the number of points the robot in question had gathered in the last tournament. This was later changed to also include survival time of the robot.

The above five programs are executed in order by a shell script “runscript” that supplies all the command line arguments needed and also repeats the procedure a set number of times.

There is also a tournament file that tells Real-time battle how many robots to use in each battle and how many battles to perform in one tournament. It is advisable that the numbers are chosen so that all robots get to fight an equal number battles, although the current evaluation program does take into account the number of battles fought. The tournament file also specifies were Real-time battle should look for the robots. See the Real-time battle documentation for a more detailed description of tournament files.

Post new comment

The content of this field is kept private and will not be shown publicly.