https://github.com/pkrystian/genetic_cars
A program that employs a genetic algorithm model to guide each generation of cars as they attempt to navigate a route created by the user.
https://github.com/pkrystian/genetic_cars
c-sharp genetic-algorithm unity
Last synced: 4 months ago
JSON representation
A program that employs a genetic algorithm model to guide each generation of cars as they attempt to navigate a route created by the user.
- Host: GitHub
- URL: https://github.com/pkrystian/genetic_cars
- Owner: PKrystian
- Created: 2023-03-05T14:07:44.000Z (over 2 years ago)
- Default Branch: senior
- Last Pushed: 2023-10-02T18:02:05.000Z (over 1 year ago)
- Last Synced: 2025-01-14T02:24:10.083Z (5 months ago)
- Topics: c-sharp, genetic-algorithm, unity
- Language: C#
- Homepage:
- Size: 69.4 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Genetic Cars
## Table of Contents
+ [About](#about)
+ [Getting Started](#getting_started)
+ [Usage](#usage)
+ [Built Using](#built_using)
## Links
+ [Download GeneticCars](https://mega.nz/file/03I0AIZS#cx4ZDJW7E4pJOXJeRG1ROTWvZQOKGGjf8nrBqH8oTKY)
+ [Unity](https://unity.com/)## About
Using a genetic algorithm model, the program teaches each generation of cars that tries to drive a route created by the user in unity.Cars start at the blue point and try to get to the red point. If they drive into a white block, their turn ends. The next generation begins after a percentage of the population has finished their turn. The next generation gets some of the genes of the best cars from the previous generation. To prevent blockages, there is a mutation factor that causes the car to run erratically. Each of the given values can be changed in the file: `Assets/Code/PopulationController.cs` .

## Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.### Prerequisites
You need to have a [Unity](https://unity.com/) installed, preferably version `2021.3.20f1` or up.
You can download files from github or from this [link](https://mega.nz/file/03I0AIZS#cx4ZDJW7E4pJOXJeRG1ROTWvZQOKGGjf8nrBqH8oTKY), remember to unzip it.
### Installing
First open Unity Hub (remeber to have a right version installed), then click `Add project from disk` option in `Open` button, choose `GeneticCars` folder that you downloaded and unziped, then open the newly created project and you're good to go.
A window with an example scene should open. Now with the `Move Tool` and `Rect Tool`, you can edit the position of all objects (remember that the spawn and target points are hidden in PopulationController layer, and are not merged with colored blocks). If you want to add new walls, copy and paste them where you want.
After setting the scene, click the `Play` button at the top of the screen and watch the cars try to find their way.
The code is in `Assets/Code/`, in order to edit variables, enter the file `PopulationController.cs` .Below are the generation steps in an example scene.
1st Generation:
5th Generation:
400th Generation:
600th Generation:
1000th Generation: