<p>In this post, I will advise you of:</p>

<ul>
<li>How to map navigational instructions to action sequences with an LSTM
neural network </li>
<li>Resources that will help you learn how to use neural
networks to accomplish your task </li>
<li>How to install and configure neural
network libraries based on what I needed to learn the hard way</li>
</ul>

<p><strong>General opinion of your idea:</strong></p>

<p>I can see what you're trying to do, and I believe that your game idea (of using randomly generated identities of adversaries that control their behavior in a way that randomly alters the way they're using artificial intelligence to behave intelligently) has a lot of potential. </p>

<p><strong>Mapping navigational instructions to action sequences with a neural network</strong></p>

<p>For processing your game board, because it involves <em>dense</em> (as opposed to <em>sparse</em>) data, you could find a Convolutional Neural Network (CNN) to be useful. However, because you need to translate the map to an action sequence, sequence-optimized neural networks (such as Recurrent Neural Networks) will likely be the most useful for you. I did find some studies that use neural networks to map navigational instructions to action sequences, construct the game map, and move a character through a game with many types of inputs:</p>

<ul>
<li>Mei, H., Bansal, M., &amp; Walter, M. R. (2015). Listen, attend, and walk: Neural mapping of navigational instructions to action sequences. arXiv preprint arXiv:1506.04089. Available at: <a href="https://arxiv.org/pdf/1506.04089.pdf" rel="noreferrer" title="Listen, Attend, and Walk: Neural Mapping of Navigational Instructions to Action Sequences">Listen, Attend, and Walk: Neural Mapping of Navigational Instructions to Action Sequences</a></li>
<li>Lample, G., &amp; Chaplot, D. S. (2016). Playing FPS games with deep reinforcement learning. arXiv preprint arXiv:1609.05521. Available at: <a href="https://arxiv.org/pdf/1603.00930.pdf" rel="noreferrer" title="Super Mario as a String: Platformer Level Generation Via LSTMs">Super Mario as a String: Platformer Level Generation Via LSTMs</a></li>
<li>Lample, G., &amp; Chaplot, D. S. (2016). Playing FPS games with deep reinforcement learning. arXiv preprint arXiv:1609.05521. Available at: <a href="https://arxiv.org/pdf/1609.05521.pdf" rel="noreferrer" title="Playing FPS Games with Deep Reinforcement Learning">Playing FPS Games with Deep Reinforcement Learning</a></li>
<li>Schulz, R., Talbot, B., Lam, O., Dayoub, F., Corke, P., Upcroft, B., &amp; Wyeth, G. (2015, May). Robot navigation using human cues: A robot navigation system for symbolic goal-directed exploration. In Robotics and Automation (ICRA), 2015 IEEE International Conference on (pp. 1100-1105). IEEE. Available at: <a href="http://eprints.qut.edu.au/82728/1/schulz-etal-ICRA-2015.pdf" rel="noreferrer" title="Robot Navigation Using Human Cues: A robot navigation system for symbolic goal-directed exploration">Robot Navigation Using Human Cues: A robot navigation system for symbolic goal-directed exploration</a></li>
</ul>

<p><strong>General opinion of what will help you</strong></p>

<p>It sounds like you're missing some basic understanding of how neural networks work, so <em>my primary recommendation to you is to study more of the underlying mechanics behind neural networks</em> in general. It's important to keep in mind that a neural network is a type of <em>machine learning</em> model. So, it doesn't really make sense to just construct a neural network with random parameters. A neural network is a machine learning model that is trained from sample data, and once it is trained, it can be evaluated on test data (e.g. to perform predictions). </p>

<p>The root of machine learning is largely influenced by Bayesian statistics, so you might benefit from getting a textbook on Bayesian statistics to gain a deeper understanding of how machine-based classification works in general. </p>

<p>It will also be valuable for you to learn the differences between different types of neural networks, such as Long Short Term Memory (LSTM) and Convolutional Neural Networks (CNNs). </p>

<p>If you want to <strong>tinker with how neural networks can be used</strong> for classification tasks, try this: </p>

<ul>
<li><a href="http://playground.tensorflow.org/#activation=tanh&amp;batchSize=10&amp;dataset=circle&amp;regDataset=reg-plane&amp;learningRate=0.03&amp;regularizationRate=0&amp;noise=0&amp;networkShape=4,2&amp;seed=0.39263&amp;showTestData=false&amp;discretize=false&amp;percTrainData=50&amp;x=true&amp;y=true&amp;xTimesY=false&amp;xSquared=false&amp;ySquared=false&amp;cosX=false&amp;sinX=false&amp;cosY=false&amp;sinY=false&amp;collectStats=false&amp;problem=classification&amp;initZero=false&amp;hideText=false" rel="noreferrer" title="Tensorflow Playground">Tensorflow Playground</a></li>
</ul>

<p><strong>To learn the math:</strong>
My professional opinion is that learning the underlying math of neural networks is very important. If it's intimidating, I give you my testimony that I was able to learn all of it on my own. But if you prefer learning in a classroom environment, then I recommend that you try that. A <strong>great resource and textbook for learning the mechanics and mathematics of neural networks</strong> is: </p>

<ul>
<li><a href="http://neuralnetworksanddeeplearning.com/" rel="noreferrer" title="Free ebook on neural networks">Neural Networks and Deep Learning</a></li>
</ul>

<p><strong>Tutorials for neural network libraries</strong></p>

<p>I recommend that you try working through the tutorials for a neural network library, such as: </p>

<ul>
<li><a href="https://www.tensorflow.org/tutorials/" rel="noreferrer" title="TensorFlow tutorials">TensorFlow tutorials</a></li>
<li><a href="http://deeplearning.net/tutorial/" rel="noreferrer" title="Deep Learning tutorials with Theano">Deep Learning tutorials with Theano</a></li>
<li><a href="https://www.cntk.ai/pythondocs/tutorials.html" rel="noreferrer" title="Tutorials with Microsoft CNTK">CNTK tutorials</a> (<a href="https://github.com/Microsoft/CNTK/blob/v2.0.beta10.0/Tutorials/CNTK_205_Artistic_Style_Transfer.ipynb" rel="noreferrer" title="CNTK 205: Artistic Style Transfer">CNTK 205: Artistic Style Transfer</a> is particularly cool.)</li>
<li><a href="https://elitedatascience.com/keras-tutorial-deep-learning-in-python" rel="noreferrer" title="Keras tutorial">Keras tutorial</a> (Keras is a powerful high-level neural network library that can use either <strong>TensorFlow</strong> or <strong>Theano</strong>.)</li>
</ul>
Clarification on a Neural Net that plays Snake
<p>I'm new to neural networks/machine learning/genetic algorithms, and for my first implementation I am writing a network that learns to play snake (<a href="http://patorjk.com/games/snake/" rel="nofollow noreferrer" title="Snake">An example in case you haven't played it before</a>) I have a few questions that I don't fully understand:</p>

<p>Before my questions I just want to make sure I understand the general idea correctly. There is a population of snakes, each with randomly generated DNA. The DNA is the weights used in the neural network. Each time the snake moves, it uses the neural net to decide where to go (using a bias). When the population dies, select some parents (maybe highest fitness), and crossover their DNA with a slight mutation chance. </p>

<p>1) If given the whole board as an input (about 400 spots) enough hidden layers (no idea how many, maybe 256-64-32-2?), and enough time, would it learn to not box itself in?</p>

<p>2) What would be good inputs? Here are some of my ideas:</p>

<ul>
<li>400 inputs, one for each space on the board. Positive if snake should go there (the apple) and negative if it is a wall/your body. The closer to -1/1 it is the closer it is.</li>
<li>6 inputs: game width, game height, snake x, snake y, apple x, and apple y (may learn to play on different size boards if trained that way, but not sure how to input it's body, since it changes size)</li>
<li>Give it a field of view (maybe 3x3 square in front of head) that can alert the snake of a wall, apple, or it's body. (the snake would only be able to see whats right in front unfortunately, which could hinder it's learning ability)</li>
</ul>

<p>3) Given the input method, what would be a good starting place for hidden layer sizes (of course plan on tweaking this, just don't know what a good starting place)</p>

<p>4) Finally, the fitness of the snake. Besides time to get the apple, it's length, and it's lifetime, should anything else be factored in? In order to get the snake to learn to not block itself in, is there anything else I could add to the fitness to help that?</p>

<p>Thank you!</p>