Welcome to the AI Racing Simulator! This project is a car racing simulator built with Python, Pygame, and NEAT (NeuroEvolution of Augmenting Topologies). The simulator uses neural networks to train virtual cars to navigate a racing track autonomously.
- Neural Network Training: Uses NEAT to evolve neural networks that control the cars.
- Pygame-based Simulation: Utilizes Pygame for rendering the cars, track, and collision detection.
- Customizable Environment: Modify the track, car size, speed, and other parameters to suit your needs.
Make sure you have the following installed:
- Python 3.x
- Pygame:
pip install pygame
- NEAT-Python:
pip install neat-python
-
Clone the repository or download the code to your local machine.
-
Prepare the environment by installing the required libraries:
pip install -r requirements.txt
-
Place your track and car image files in the same directory as the script. The simulator uses
car.png
for the car image andsilverstone.png
for the track. -
Run the simulator:
python ai_racing_simulator.py
The simulator is configured using the config.txt
file, which specifies the parameters for the NEAT algorithm, such as population size, mutation rates, etc. You can adjust these settings to experiment with different configurations and see how they affect the performance of the neural networks.
- The neural network controls the car automatically.
- No manual input is required during the simulation.
- Each generation, a population of neural networks is created and evaluated.
- Each neural network controls a car, using sensors (radars) to detect distances to the track borders.
- Cars receive rewards based on the distance traveled without crashing. The networks with the highest rewards are selected and mutated to create the next generation.
You can customize various aspects of the simulator, including:
- Track and Car Images: Replace
car.png
andsilverstone.png
with your own images. - Car Behavior: Adjust parameters in the
Car
class, such as speed, radar range, collision detection, and rewards. - Neat Configuration: Modify
config.txt
to change neural network settings like the number of nodes, activation functions, or the maximum number of generations.
This project is licensed under the MIT License - see the LICENSE file for details.
- NEAT-Python for the NEAT algorithm.
- Pygame for the game engine.