Giter Site home page Giter Site logo

kaifishr / spacedrones Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 24.04 MB

A simple learning environment with space drones for evolution-inspired optimization.

License: MIT License

Python 100.00%
box2d-physics-engine evolutionary-algorithms genetic-algorithm machine-learning optimization pygame python evolution-strategies

spacedrones's Introduction

SpaceDrones ๐Ÿš€

SpaceDrones provides a simple learning environment for evolution-based optimization with many possible extensions.

Under the hood, SpaceDrones uses PyBox2D for the rigid physics simulation and Pygame for rendering and visualization.

The drones' behavior is controlled by a reward function. The example below shows non-interacting drones trying to follow a target. The red lines show the force with which the rocket engines are run.

The following graph shows the average reward over a period of about 3000 generations.

Installation

To run SpaceDrones, install the latest master directly from GitHub. For a basic install, run:

git clone https://github.com/kaifishr/SpaceDrones
cd SpaceDrones
pip install -r requirements.txt

Then start the optimization by running:

python train.py

Evaluate the progress by running:

python eval.py

Visualization can be turned on and off by clicking on the Pygame window or by pressing Space. Turning off visualization greatly accelerates the optimization process. Ray casting can also be turned off by pressing r.

Method

SpaceDrones uses PyBox2D to create a physical environment the drones can interact with. Drones use raycasting to gather distance information about obstacles in their surroundings. This information is fed into the drone's neural network to predict the next set of actions. These actions are passed on to the engines, which then command the power at which they should run.

The drones' fitness depends on the defined reward function. The neural network weights of the fittest drone are mutated and passed on to the next generation of drones.

The implementation allows for deactivating drones of the current generation when they collide with other objects.

The drone's brain is modeled by a multilayer perceptron neural network implemented in NumPy.

Learning

The reward function controls the learning behavior of the drone. As a default, the fitness score depends on how much distance has been covered by the drone and how close it flies to obstacles. The reward function can be modified as desired.

SpaceDrones lets you modify many hyperparameters that affect how fast and what the drones learn. Most of the hyperparameters can be found in the config.yml file.

Maps

SpaceDrones has different maps that vary in difficulty. Depending on the map, the drones learn different flight behaviors. Maps can be easily added or modified.

References

Citation

If you find this project useful, please use BibTeX to cite it as:

@article{fischer2022spacedrones,
  title   = "SpaceDrones",
  author  = "Fischer, Kai",
  journal = "GitHub repository",
  year    = "2022",
  month   = "July",
  url     = "https://github.com/kaifishr/SpaceDrones"
}

License

MIT

spacedrones's People

Contributors

kaifishr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

simrit1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.