Car trained using genetic algorithm in Unity Engine
Steps:
- Import car from standard assets in Unity.
- Attach CustomCarController.cs to it.
- Create empty game object and attach Nature.cs
- Drag car from scene to the variable of Nature.cs in the inspector panel.
- Create UI with two text objects.
- Drag one into PopulationText variable of Nature.cs and another on StatsText of CustomCarController.cs
- To save best NN, place an empty collider behind the car. Make sure that isTrigger is checked.
- The finish object should have tag set to "Finish"
- The walls of the track should have tag set to "Wall"
- Change speed limit of the Car to tune training.
nn.txt contains trained weights. Check Load From File on the GameObject which has Nature.cs attached. This will load pre trained weights.
- Matrix class
- Test on unknown track
- Parallel Training
- Ability to speedup training
- Optimize bias and weight ranges
- The matrix multiplication is hard coded. Needs to be changed
Read the blog post on what inspired me to take up this project and how I went about it.