This is the repository of my final project for the class "Theory, Programming and Simulation of Neural Networks". The goal of this project was to evolve an agent function for a maze solving agent by genetic programming. This README is based on Version 2
of the implementation. In Version 1
of the implementation the return values and parameters of the functions referenced here could be different.
- In a Unix Shell run
java -jar gp_maze_solver_v<versionnumber>.jar <command>
- In Eclipse the commands can be set under
Run As > Run Configurations > Arguments > Program Arguments
The following commands are available for execution:
evolve <populationsize> <numberoffitnessfunction> <mazenumber>
: runs genetic programming on the selected maze with the selected fitness function and population size and returns an agent function.run <mazenumber>
: shows the selected maze while an agent tries to find the exit.show <mazenumber>
: only shows the selected maze. The <mazenumber> has to be between 1 and 6 and the <numberoffitnessfunction> between 1 and 3. The <populationsize> can be any number (1000 is recommended).
All other options can be set in the file Config.java
.
An evolved agent function can be added by using the template EvolvedAgentFunctionExample.java
:
- Copy
EvolvedAgentFunctionExample.java
and insert the evolved agent function into the functionETurn evaluate(Maze pMaze, EOrientation pOrientation) { PASTE EVOLVED AGENT FUNCTION HERE }
. - In the function
void withWindow(int mMazeNumber, boolean run)
of the fileMain.java
make a new object of the evolved agent function and name itroot
. - Use the command
run <mazenumber>
to see how the agent function performs in the selected maze (needs to be recompiled when using a Unix Shell).
Until now, no maze generation algorithm is implemented. Mazes are all hardcoded. A new maze can be added in the following way:
- Add a new function
int[][] maze<mazenumber>()
into theMazeBuilder.java
file. Include your maze into this function. Call this function in the return statement of the functionint[][] build(int pMazeNumber)
. - Make sure that the new number is accepted as a command line argument and by the the mazenumber check in the function
int[][] build(int pMazeNumber)
of the fileMazeBuilder.java
. - Make sure that the maze values in
Config.java
are set correctly. - Use the maze with one of the commands mentioned above.