This is part of an ongoing series in which we experiment with different methods of AI. We’ll look at the state of the art and the out of fashion; the practical and the (seemingly) impractical; to find what works and what doesn’t. In this part, we will be writing the Neural Network that will control our UFOs. You can read the first part in the series for more information on what we are trying to accomplish. You can also see my earlier article for the background and (a tiny bit) of the maths surrounding artificial neural networks, however, I’ll re-iterate the important parts and expand on parts as necessary.
An Artificial Neural Network (ANN) is a number of neurons connected in some way to form a network.
x1w1 + x2w2 + …xnwn – t >= 0
So the threshold can be seen as a weight that is always multiplied by a -1, we call this the bias and is why we have included an extra weight. Now when we are evolving the network we’ll also evolve this threshold value as it is stored along with the weights.
The inputs into the network are passed in as a vector of floats. The function then loops through each layer processing each neuron summing up the inputs multiplied by the weights and calculating each neuron’s activation by putting the total through the Sigmoid function. I use a faster version of the sigmoid function, while not as accurate (the UFOs don’t mind), it is quite a bit quicker. The function returns a vector of floats that correspond to the outputs from the ANN. We’ll use this output in the next tutorial to control the movement of our UFOs.