Created by Josh Rickert for CSE 231 at Michigan State University, Spring 2010
Updated for Python 3.4.0
This script uses a genetic algorithm to teach a 'robot' to navigate a 'maze' (provided by a text file). The robot has a location, facing, and sensor values. It can move forward, left or right. Each robot has a Braitenberg matrix genome that parses its sensor input into instructions to move. The successful robot will follow a breadcrumb trail 'b' to a goal point 'F'.
Load main.py and run runGA() from the console.
The default parameters for the simulation are optimized for a successful navigation. To demonstrate the effectiveness of the algorithm, decrease the starting population, offspring population size, or other parameters to produce a stupider result.
Three main classes:
- GA() maintains the population of individuals and simulates their interactions.
- Individual() represents a single individual and an instance of its environment.
- World() is imported and represents the environmental simulation for a single individual.
During the simulation, for each generation:
- Create the offspring by choosing fit parents and crossing their genes
- Mutate the offspring at user-determined rates
- Add the offspring to the main population
- Kill off the weakest members of the population
- Output the strongest member of the population
- 'b' is a breadcrumb
- 'x' is a wall
- 'A' is an agent
- '-' is an empty space
- '=' is the robot's path
- 'F' is the finish spot