Project: Autonomous Creatures Part 3
The creature now has enemies! Oh no, how evil of me… >:)
I’ve also solved the problem of calculating and inputting the co-ordinates of the enemy into the neural net. Basically, the number of radians from north is calculated for each of the enemy, and then this information is converted into sections (like a pie), before going into the neural net of the creature.
A problem I had was that the angle calculated using numpy resulted sometimes (when the creature was to the right of the enemy) in an angle that was from the north, but from the other side (anti-clockwise instead of clock-wise). This was quite easily solved though.
Here’s that piece of code:
So, when the simulation is run, the section for each enemy is calculated before being entered into the neural network with a set input of 100 (I was just picking a relatively large number). However, I noticed that sometimes the creature would just become stuck because every enemy affected it the same way with no regard for proximity. So, I used some basic maths and worked out the distance for each one and used that as the input into the neural network.
Now, we just need to apply genetic algorithms to it, which should be pretty formulaic. Yay!