GAME AI USING PHASER.IO AND SYNAPTIC : PART 2

In the previous tutorial, we have implement the game part. We now need to add our neural network to the game to automate player jumps. Make sure to download the complete project files.

Download

&

Presentation slides

Before we start, we need to get introduced to some ANN(Artificial neural network) terms!

Terminology

Neural Networks :

  • Inspired from human brain design.
  • Interconnected processing elements (neurons) working in unison to solve specific problems.

Supervised Learning:

  • We teach the neural network with input and output patterns, so that next time something similar comes, it know what to do.

Perceptron:

  • Perceptron is an algorithm for supervised learning.
  • It is a type of linear classifier, i.e. a classification algorithm that makes its predictions based input and weight of each edge in the neuron.

Let’s see some code

ANN variables :

Initializing ANN :

Training ANN :

Activating ANN and getting the respective output of custom input

Calling train_nn()

getting training dataset :

In order to get the training dataset(during manual mode) for this supervised learning network, we are getting displacement and speed value at each frame in the update().

we get the ball’s speed from the fire function

 

Making the automated jump 

It is also done in the update()

GAME DEMO: