Snake Neuroevolution - Snakes going mad :))
Hello everyone, I have a more complex issue regarding a more complex problem. I have this app, which shows an animation of snakes (from the POPULAR game of "Snake") that learn to win the game using a genetic algorithm. It works like this: * A Snake Object Pool of 50 snakes with an individual "brain" as a Neural Network * Each snake tries the game until it dies * Each snake will have a score and at the end of the generation, the following happen: * Fitnesses are calculated as normalized values * The best 6 snakes from the current generation are chosen * There are 10% chances a brain is mutated * Two random brains are chosen and they crossover to make a new one * The new brains are given to the snakes and the next generation begins * Each neural network is made of 5 input nodes, The problems are: * The most important one is that after a few generations, the snake just follows the nearest wall. * Apparently I don't know how to fix to the loopworm bug, where the snakes just go in a loop. I tried decreasing the score when they get further away, but it also affects the other snakes The Neural Network library is taken from the Coding Train on Youtube, and the playlist that shows you how it was created is here: https://www.youtube.com/watch?v=XJ7HLz9VYz0&list=PLRqwX-V7Uu6aCibgK1PTWWu9by6XFdCfh The project I am talking about is on Github here: https://github.com/gamirou/SmartSnake Thank you everyone!