| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Welcome to the N-Body Problem Simulation with NEAT AI project! This Python-based simulation leverages the power of the NEAT (NeuroEvolution of Augmenting Topologies) algorithm to evolve and simulate the motion of multiple planetary bodies under gravitational forces. This project uses Pygame for visualizations and NEAT-Python for neural network evolution.
This project simulates an N-body gravitational system, where planets are attracted to each other following Newton's law of gravitation. It uses a neural network evolved with NEAT to determine the initial conditions (position and velocity) for each planet. The goal is to evolve stable or interesting systems using fitness-based evaluations.
The core idea is to explore how neural networks can generate stable orbits or controlled planetary systems in a dynamically evolving gravitational context.
Clone the Repository:
git clone https://github.com/corzed/n-body-problem-ai.git
cd n-body-neat-simulationCreate a Virtual Environment (Optional but recommended):
python -m venv env
source env/bin/activate # On Windows, use `env\Scripts\activate`Install Dependencies:
pip install -r requirements.txtMake sure you have the following dependencies:
Run the Simulation:
python ai.pyAfter running the script, the program will prompt you to select the number of planets to simulate. You can then choose to start a new training session or load from a saved checkpoint.
The configuration file for NEAT is automatically generated as config-feedforward.txt and contains adjustable parameters for:
Feel free to modify this file as needed to experiment with different evolutionary parameters.
n-body-neat-simulation/
│
├── ai.py # Main script for simulation and neural network evolution
├── config-feedforward.txt # Configuration file for NEAT
├── requirements.txt # Dependencies
└── README.md # Project documentation
The core algorithm used in this simulation is NEAT (NeuroEvolution of Augmenting Topologies), which evolves a neural network to optimize the initial conditions for the planetary bodies. Here's a deeper look into how this works:
The neural network evolved by NEAT takes a simple input vector to generate initial positions and velocities for each planet. The inputs consist of a constant bias (e.g., 1.0) to allow the neural network to generate consistent outputs. The outputs represent:
The NEAT algorithm optimizes the neural network's weights, connections, and even its topology to find the best configuration for creating stable planetary orbits. This is achieved through:
The fitness function measures the stability and behavior of the planetary system:
NEAT applies mutations and crossovers to generate a new population in each generation:
The neural networks are trained over multiple generations, with the fitness of the best neural network being plotted over time. You can visualize the results in real time using Pygame.
The simulation is visualized using Pygame, which displays the current planetary system's state. Information such as generation, genome ID, fitness, and simulation speed is displayed in the Pygame window.
This project is licensed under the MIT License. See the LICENSE file for details.
Happy Simulating! 😊🚀🌌
| Back | FazBrowse Home | New Git URL |