Code Monkey home page Code Monkey logo

godot-neural-networks's Introduction

Godot Neural Networks GDNative library (GNN)

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.


How to Build

For building copy godot-cpp in the main folder and build godot-cpp for your platform and target of choice. If you don't know how to build godot-cpp take a look at this page

after that use scons to build the GDNative library for godot

scons platform=[Your platform] target=[release or debug]

Classes

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.

Network Class

methods

  • add_layer()
  • init()
  • feedforward(input)
  • get_layers()
  • get_layer(Layer_index)
  • randomize_weights()
  • randomize_biases()
  • get_id()
  • size()
  • print()
  • scan()
  • load()
  • save()

GDNetwork Class (inherit from Network)

This class has all methods of Network class, with this additional methods:

methods

  • train(input, target)

properties

  • wlr weights learning rate
  • blr biases learning rate

GANetwork Class (inherit from Network)

This class has all methods of Network class, with this additional methods:

methods

  • mutate()
  • crossover(another GALayer)

properties

  • fitness
  • normalized_fitness
  • age
  • mark_for_kill

Population Class

methods

  • init(GANetwork)
  • arr_init(Array of GANetwork)
  • get_networks()
  • randomize()
  • epoch()
  • get_bests()

peropeties

  • size
  • crossover_rate
  • mutation_rate
  • mutation_power
  • keep_best_rate
  • kill_worse_rate
  • max_fitness
  • mean_fitness
  • generation

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.