[Solved] How to use Recurrent Neural Network to play simple 2D Java game?


Some good library’s can be found in GitHub but that’s not what you should be looking for. To start up you need a training technique for your RNN, i would personally recommend NEAT (Neuroevolution of augmenting topologies) which uses RNN in a Genetic Algorithm, there is many videos explaining how it works and implementations in games like Snake (Like here: https://www.youtube.com/watch?v=BBLJFYr7zB8). If you go to GitHub and just right “Neural Network Neat” you will find multiple repos that all is left to do with them is implement!

You can also use back propagation or qlearning but i personally think bp isless effective in this specific scenario and ql is a bit to advanced if this is your first ml project.

i recommend this repo not because its good but because its simple and it gets the idea through (https://github.com/fabiorino/NeuralNetwork-plays-Pong)

Here is what you need to do to implement it!

  • Go to the main class which in our case is Pong
  • Create input array which is actually just a array of double
  • Change the inputs in learn() in this line “outputs = nn.getOutputs(inputs);”
  • Change the fitness score in gameOver()
  • change what happens in gameover()

And i think thats it!

Hope i helped and good luck!

solved How to use Recurrent Neural Network to play simple 2D Java game?