All Projects → ArztSamuel → Applying_eanns

ArztSamuel / Applying_eanns

Licence: mit
A 2D Unity simulation in which cars learn to navigate themselves through different courses. The cars are steered by a feedforward neural network. The weights of the network are trained using a modified genetic algorithm.

Projects that are alternatives of or similar to Applying eanns

Genann
simple neural network library in ANSI C
Stars: ✭ 1,088 (-0.46%)
Mutual labels:  neural-networks, genetic-algorithm, artificial-neural-networks
Geneticalgorithmpython
Source code of PyGAD, a Python 3 library for building the genetic algorithm and training machine learning algorithms (Keras & PyTorch).
Stars: ✭ 435 (-60.2%)
Mutual labels:  neural-networks, genetic-algorithm, evolutionary-algorithms
GeneticAlgorithmForFeatureSelection
Search the best feature subset for you classification mode
Stars: ✭ 82 (-92.5%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
NEATEST
NEATEST: Evolving Neural Networks Through Augmenting Topologies with Evolution Strategy Training
Stars: ✭ 13 (-98.81%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
Awesome Ai Awesomeness
A curated list of awesome awesomeness about artificial intelligence
Stars: ✭ 268 (-75.48%)
Mutual labels:  neural-networks, artificial-neural-networks
goga
Go evolutionary algorithm is a computer library for developing evolutionary and genetic algorithms to solve optimisation problems with (or not) many constraints and many objectives. Also, a goal is to handle mixed-type representations (reals and integers).
Stars: ✭ 39 (-96.43%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
evoli
Genetic Algorithm and Particle Swarm Optimization
Stars: ✭ 22 (-97.99%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
tiny gp
Tiny Genetic Programming in Python
Stars: ✭ 58 (-94.69%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
Dissecting Reinforcement Learning
Python code, PDFs and resources for the series of posts on Reinforcement Learning which I published on my personal blog
Stars: ✭ 512 (-53.16%)
Mutual labels:  neural-networks, genetic-algorithm
Hyperparameter Optimization Of Machine Learning Algorithms
Implementation of hyperparameter optimization/tuning methods for machine learning & deep learning models (easy&clear)
Stars: ✭ 516 (-52.79%)
Mutual labels:  genetic-algorithm, artificial-neural-networks
Pagmo2
A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
Stars: ✭ 540 (-50.59%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
TorchGA
Train PyTorch Models using the Genetic Algorithm with PyGAD
Stars: ✭ 47 (-95.7%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
zoofs
zoofs is a python library for performing feature selection using a variety of nature-inspired wrapper algorithms. The algorithms range from swarm-intelligence to physics-based to Evolutionary. It's easy to use , flexible and powerful tool to reduce your feature size.
Stars: ✭ 142 (-87.01%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
GeneticsJS
Evolutionary algorithms library for the web 🧬
Stars: ✭ 25 (-97.71%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
NeuroEvolution-Flappy-Bird
A comparison between humans, neuroevolution and multilayer perceptrons playing Flapy Bird implemented in Python
Stars: ✭ 17 (-98.44%)
Mutual labels:  genetic-algorithm, artificial-neural-networks
neuroevolution-robots
Neuroevolution demo through TensorFlow.js, Neataptic, and Box2D
Stars: ✭ 31 (-97.16%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
GARI
GARI (Genetic Algorithm for Reproducing Images) reproduces a single image using Genetic Algorithm (GA) by evolving pixel values.
Stars: ✭ 41 (-96.25%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
wargames
two soldiers shooting at each other, controlled by a neural network with a genetic algorithm.
Stars: ✭ 22 (-97.99%)
Mutual labels:  genetic-algorithm, artificial-neural-networks
Eaopt
🍀 Evolutionary optimization library for Go (genetic algorithm, partical swarm optimization, differential evolution)
Stars: ✭ 718 (-34.31%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
Jenetics
Jenetics - Genetic Algorithm, Genetic Programming, Evolutionary Algorithm, and Multi-objective Optimization
Stars: ✭ 616 (-43.64%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms

Applying Evolutionary Artificial Neural Networks

A 2D Unity simulation in which cars learn to navigate themselves through different courses. The cars are steered by a feedforward Neural Network. The weights of the network are trained using a modified genetic algorithm. Short demo video of an early version: https://youtu.be/rEDzUT3ymw4

The Simulation

Cars have to navigate through a course without touching the walls or any other obstacles of the course. A car has five front-facing sensors which measure the distance to obstacles in a given direction. The readings of these sensors serve as the input of the car's neural network. Each sensor points into a different direction, covering a front facing range of approximately 90 degrees. The maximum range of a sensor is 10 unity units. The output of the Neural Network then determines the car’s current engine and turning force.

If you would like to tinker with the parameters of the simulation, you can do so in the Unity Editor. If you would simply like to run the simulation with default parameters, you can start the built file [Builds/Applying EANNs.exe](Builds/Applying EANNs.exe).

The Neural Network

The Neural Network used is a standard, fully connected, feedforward Neural Network. It comprises 4 layers: an input layer with 5 neurons, two hidden layers with 4 and 3 neurons respectively and an output layer with 2 neurons. The code for the Neural Network can be found at UnityProject/Assets/Scripts/AI/NeuralNetworks/.

Training the Neural Network

The weights of the Neural Network are trained using an Evolutionary Algorithm known as the Genetic Algorithm.

At first there are N randomly initialised cars spawned. The best cars are then selected to be recombined with each other, creating new "offspring" cars. These offspring cars then form a new population of N cars and are also slightly mutated in order to inject some more diversity into the population. The newly created population of cars then tries to navigate the course again and the process of evaluation, selection, recombination and mutation starts again. One complete cycle from the evaluation of one population to the evaluation of the next is called a generation.

The generic version of a Genetic Algorithm can be found at UnityProject/Assets/Scripts/AI/Evolution/GeneticAlgorithm.cs. This class can be modified in a very easy way, by simply assigning your own methods to the delegate operator methods of the class. Some example code for adapting the Genetic Algorithm to your own needs can be found in the EvolutionManager UnityProject/Assets/Scripts/AI/Evolution/EvolutionManager.cs, which is already able to switch between two differently modified Genetic Algorithms.

User Interface

The user interface always displays the data of the current best car. In the top left corner the Neural Network's output (engine and turning) is displayed. Right below the output, the evaluation value is displayed (the evaluation value is equal to the percentage of course completion). In the lower left corner a generation counter is displayed. In the upper right corner the Neural Network of the current best car is displayed. The weights are symbolised by the color and width of the connections between neurons: The wider a connection, the bigger the absolute value of the weight; Green means that the weight is positive, red means that the weight is negative.

The entire UI-code is located at UnityProject/Assets/Scripts/GUI/.

Courses

There are multiple courses of different difficulties which are all located in different unity scenes and can be found in the folder UnityProject/Assets/Scenes/Tracks/.

In order to start the simulation on a specific course, open the Main scene and enter the desired track-name (= scene name) in the Inspector of the GameStateManager object.

Two different courses the cars can be trained on.

License

Feel free to use my code in your personal projects. I would be very interested in any work that originates from this project. I would be more than happy to hear from your impressions and results, so feel free to mail me at [email protected]. You can also follow me on twitter: https://twitter.com/SamuelArzt

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].