https://github.com/apisarenco/naive-n-body-sim
Naive n-body simulation
https://github.com/apisarenco/naive-n-body-sim
jit kiss-principle n-body-simulator physics-simulation pyglet
Last synced: 3 months ago
JSON representation
Naive n-body simulation
- Host: GitHub
- URL: https://github.com/apisarenco/naive-n-body-sim
- Owner: apisarenco
- License: mit
- Created: 2019-05-29T22:55:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-18T09:35:49.000Z (over 2 years ago)
- Last Synced: 2024-11-30T05:42:32.440Z (10 months ago)
- Topics: jit, kiss-principle, n-body-simulator, physics-simulation, pyglet
- Language: Python
- Size: 7.81 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Naive n-body simulation

This is a naive algorithm that simulates attraction between objects dependent on their mass, plastic collisions, etc.
This is bad code. Don't use this in real games. It's O(n^2) complexity, and doesn't leverage any linear algebra power. The only thing fast in it is pyglet, numba and a few simplifications in the computations.
## Why?
* To show that it's easy, fast, and fun. Easy relatively speaking. If you're not comfortable with looping through lists while manipulating them, this might seem complex, but don't let that deter you from learning.
* To show the power of Numba (go ahead, try it, comment it out)
* To show that pretty stuff doesn't have to be thousands of lines of code
## How to run?
Clone this repository
```
git clone https://github.com/apisarenco/naive-n-body-sim.git
```Install the dependencies using [pip](https://pip.pypa.io/en/stable/installing/) and the `requirements.txt` file within the repository. You might want to create and activate a [virtualenv](https://www.pythoncentral.io/how-to-install-virtualenv-python/) first.
```
pip install -r requirements.txt
```Run
```
python main.py
```