Implementation of Genetic Algorithm on 2D grid. Green tiles are `Plants`, red tiles are `Eaters` and black tiles are `Walls`. ----------------------GETTING STARTED---------------------- 1. Press `Green Flag` to run algorithm. 2. Wait until evolution runs till the end given by MAX_YEARS variable OR press `r` to prematurely stop. 3. Press `l` to view the average fitness plotted against year. 4. Press `r` to clear. Then Press `i` to initialize to the grid with a random distribution of tiles. Then you can place tiles manually by mouse clicking and toggling between tile types with (1-4, see CONTROLS). 5. Press `space` to begin algorithm for new initial state` ------------------------------------------------------------ ------------------------CONTROLS------------------------ - r: Stop running algorithm and clear grid - i: Random initialize grid - l: Plot the average fitness over years (after algorithm has finished running or premature stop with `r`). Press `r` to go back to grid. - mouse click: Manually place tiles (after pressing `r`) according to mouse_mode - 1: set mouse_mode to WALL - 2: set mouse_mode to EMPTY - 3: set mouse_mode to PLANT - 4: set mouse_mode to EATER ------------------------------------------------------------ **Detailed explanation of the setup is given in the link in the `Notes and Credits` section. ------------------------SETUP------------------------ - Eaters move around the world (2D grid) and eat Plants. - The fittest individual is given by the Eater that manages to eat the most. - The Eaters can only move forward, move backwards, rotate 90 degree CW and rotate 90 degree ACW. - The evolutions runs for Years with each Year consisting of 365 Days (365 updates before breeding new generation). - Plants regrow as they are eaten. ------------------------------------------------------------
The implementation comes from http://math.hws.edu/xJava/GA/