A 2D self‑driving car simulation built with JavaFX, where cars learn to navigate a track and avoid collisions using a Neural Network trained via a Genetic Algorithm. The application allows users to visually train, observe, and evolve autonomous agents in real time.
- 2D Self‑Driving Cars rendered with JavaFX
- Neural Network Controller for decision‑making
- Genetic Algorithm Training (selection, crossover, mutation)
- Real‑time Visualization of training progress
- Collision Detection with track boundaries and obstacles
- Generation‑based Evolution with fitness scoring
- User Controls to start, pause, reset, and observe training
Each car is controlled by a feed‑forward neural network that:
- Takes sensor inputs (distance to walls)
- Produces outputs such as steering direction and acceleration
The neural network weights define the "brain" of each car.
Cars improve over generations using a genetic algorithm:
-
Initialization – Start with a population of random cars
-
Evaluation – Each car is assigned a fitness score based on:
- Distance traveled
- Time alive
-
Selection – Top‑performing cars are selected
-
Crossover – Neural networks are combined
-
Next Generation – A new population is created and trained
Over time, cars learn to avoid collisions and drive more efficiently.
- Clone this repository
- Remove the
.gitdirectory - Add the cloned directory structure to your local repo (if you already have one)
- Open the project with NetBeans
- Using NetBeans, build the project to resolve the dependencies
- Change the project name in
settings.gradle - Rename the default Java package in
MainApp.javaandMainAppController.java. - Change the value of the
mainClassclass property inbuild.gradle. A fully-qualified name of the class containing the main method that you want to run must be supplied.
This project template was tested with NetBeans 17 and JDK 18.
