After trying many times over the last few months I have succeeded at making a neural network that learns. This example is very dull and boring but demonstrates quite well (and quickly) how the bot learns. This is not interactive. You simply watch the bots improve at the 'game'.
- The bots spawn in random places and move in directions according to their 'brain' (AI)
- They must always move
- If they hit the boundary then they 'die'
- The boundary shrinks, meaning eventually the will all die
- When the boundary is small the sim resets and the bots respawn again
- The bots are rewarded by not dying. Each bot has a 'score' which is their age (in seconds)
This is a 2-2-4 neural network with a genetic algorithm and sigmoid activation.
All the bots start with a random DNA and move according to their 'brain' (neural network). Each brain has slightly different DNA so each brain appears to be behaving like all the other brains but there are small differences your eye won't detect.
When a bot dies, or the sim resets (end of the generation), the two oldest bots are considered the strongest and their DNA is preserved. All bots that spawn from that point will use a mix of those two DNA (plus a randomly introduced element).
If the mix of those two parent DNA's produce a bot that survives even longer then that is a stronger survivor and that DNA is preserved by joining the top two strongest DNA (bumping another DNA out).
Over many iterations and generations (takes hours) the gene pool strengthens and the bots start to learn which DNA gives them the greatest chance of surviving.
Eventually you will see bots congregating around the middle of the screen as this puts the most distance between them and the boundary and therefore increases their chances of survival.
Lessons learned from this tiny project will be applied to my next AI project.
Show off your games, demos and other (playable) creations.
2 posts • Page 1 of 1
Nice! At first it's not impressive until you realize how it was done I guess. Maybe next youncould try a text based one that shows people/creatures doing a bunch of actions and learning from them to survive
Users browsing this forum: No registered users and 15 guests