Introducing you to a project that implements a solution to the classic Lunar Lander problem using the NEAT (NeuroEvolution of Augmenting Topologies) algorithm using the Gymnasium Environment
Demonstration of a trained neural network successfully landing the spacecraft
The Lunar Lander environment is a classic problem where the goal is to safely land a spacecraft on the moon's surface. In this project, we employ the NEAT algorithm to evolve neural networks that can control the lander to achieve a safe landing.
This project implements Reinforcement Learning through neuroevolution. The NEAT algorithm evolves neural networks that learn optimal control policies through interaction with the environment. The networks receive state observations as input and output control actions, improving their performance through evolutionary selection.
lunar_lander_neat.py: The main script that sets up the environment and runs the NEAT algorithm.config-feedforward.txt: Configuration file for the NEAT algorithm.visualize_network.py: Utility script to visualize the neural network architectures evolved by NEAT.result.txt: Contains results from my NEAT runs.
To run this project, follow these steps:
-
Clone the repository:
git clone https://github.com/RiddhiRaj/lunar-lander.git cd lunar-lander -
Set up a Python virtual environment (miniconda):
On Windows:Follow this video: https://youtu.be/gMgj4pSHLww?si=2RrSagciWi8ybbx0 (it does not work otherwise)
On Unix or MacOS:Follow the official github of Gymnasium: https://github.com/Farama-Foundation/Gymnasium
-
Install the required dependencies:
Ensure you have Python installed. Then, install the necessary packages:
pip install -r requirements.txt
-
Run the NEAT algorithm:
Execute the main script to start the training process:
python lunar_lander_neat.py
The script will evolve neural networks to control the lunar lander. Training progress and results will be displayed in the console.
-
Visualize the results:
After training, you can visualize the evolved neural network using:
python visualize_network.py
This will generate a graphical representation of the best-performing neural network.
This project utilizes the NEAT-Python library for implementing the NEAT algorithm. For more information on NEAT and its Python implementation, visit the NEAT-Python documentation.
Feel free to explore the code and experiment with different configurations to improve the lander's performance or maybe optimize it with other methods. Happy coding!
