项目作者: imshreyshah

项目描述 :
Toy race car trained using Genetic Algorithm and Particle Swarm Optimization.
高级语言: Python
项目地址: git://github.com/imshreyshah/Racing-Car-GA-PSO.git
创建时间: 2021-06-19T06:11:36Z
项目社区:https://github.com/imshreyshah/Racing-Car-GA-PSO

开源协议:

下载


Racing Car using GA/PSO algorithm

This project consists of creating a toy car racing enviroment, where we can train our car to complete a race track, by training it on multiple tracks using the Genetic Algorithm(GA) and PSO(Particle Swarm Optimizer) algorithm. This project was done as a part of the course Neural Networks and Fuzzy Logic at BITS Pilani.

Code Files

Tracks - Directory that contains the tracks used for training. Sample tracks have been added.

Visualization - Directory where the GIFs of how the race car performs on the tracks are stored.

Weights - Directory where the weights are stored after training.

base_car.py - Contains the Car class that implements most of the functionalities.

car_gapso_imp.py - Contains template for GA/PSO training. It also contains the mechanism through which the car moves.

train_ga.py - Training script for training the car based on Genetic Algorithm.

train_pso.py - Training script for training the car based on PSO algorithm.

car_custom_imp.py - Contains template for GA/PSO training. It also contains the mechanism through which the car moves.

custom_train.py - Loads the custom car implemented in car_custom_imp.py and finds the fitness on different tracks.

How to Run

Optionally, create a virtual environment on your system and open it.

To run the project, first clone the repository by typing the command in git bash.

  1. git clone https://github.com/imshreyshah/Racing-Car-GA-PSO.git

Alternatively, you can download the code as .zip and extract the files.

Shift to the cloned directory

  1. cd Racing-Car-GA-PSO

To install the requirements, run the following command:

  1. pip install -r requirements.txt

Run the training script for the algorithm you want to use.

To run the GA algorithm, use the following command:

  1. python train_ga.py

The visualizations would be stored in the visualization directory.

The sample outputs would look like: -

Sample output 1

Sample output 2

Sample output 3

Acknowledgement

Thanks to the Instructor and the Teacher’s Assistants for implementing many functionalities of this assignment.