Orginal Author's video about using this library (should still be pretty much the same)
Video Tutorial
https://www.youtube.com/playlist?list=PLhixpuPeRv9ZUP2EbfHot8eHRhUIaneMg
Simply create a Neural Networks for your game in Godot which is able to learn how to play. This Neural Networks library uses two methods for learning one of the is backpropagation and the other is Genetic algorithm, in-game because we don't have training data we usually use Genetic algorithm to teach the Neural Network.
You also will be able to use this library only in c++ without Godot if you want.
Building GDExtnsions is not properly documented by godot at this time, but this page as is somewhat useful page
Build most resent version of godot
./godot.linuxbsd.tools.64 --dump-extension-api extension_api.json
copy gdnative_interface.h and extension_api.json from godot files into godot-cpp
build godot-cpp
copy godot-cpp folder into root directory of this project (or wherever your scons file says godot-cpp is)
use scons to build the GDExtension library for godot
scons platform=[Your platform] target=[release or debug]
There are four main classes which you should use to create and train Neural Networks
- Network: This class only create a network and is able to process the inputs and obtain outputs. But it is not able to train the Neural Networks, You can use this class when you already trained your Neural Networks and you need only to run it.
- Layer: Each network contain multiple layers which contain values, weights and biases, you should never create a Layer by yourself instead you should network method add_layer().
- GDNetwork (inherit from Network): This class use Backpropagation (Gradient descent) algorithm to teach the network. This method needs a set of data with answers.
- GDLayer(inherit from Layer): Each GDNetwork contain multiple layers which contain values, weights, biases and errors, you should never create a GDLayer by yourself instead you should GDnetwork method add_layer().
- GANetwork (inherit from Network): Use this for Genetic algorithm to teach the networks.
- GALayer(inherit from Layer): Each GANetwork contain multiple GALayers which contain valuers, weights and biases, you should never create a GAlayer by yourself instead you should GANetwork method add_layer().
- Population: Manage many GANetworks and create new GANetworks for next generation.
- add_layer()
- init()
- feedforward(input)
- get_layers()
- get_layer(Layer_index)
- randomize_weights()
- randomize_biases()
- get_id()
- size()
- print()
- scan()
- load()
- save()
This class has all methods of Network class, with this additional methods:
- train(input, target)
- wlr weights learning rate
- blr biases learning rate
This class has all methods of Network class, with this additional methods:
- mutate()
- crossover(another GALayer)
- fitness
- normalized_fitness
- age
- mark_for_kill
- init(GANetwork)
- arr_init(Array of GANetwork)
- get_networks()
- randomize()
- epoch()
- get_bests()
- size
- crossover_rate
- mutation_rate
- mutation_power
- keep_best_rate
- kill_worse_rate
- max_fitness
- mean_fitness
- generation