My first successful Neural Network (AI)

Show off your games, demos and other (playable) creations.
Post Reply
togFox
Party member
Posts: 399
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

My first successful Neural Network (AI)

Post by togFox »

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'.

AI rules
- 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)

AI learning
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. :)

unknown.png
unknown.png (14.37 KiB) Viewed 3595 times
nn.love
(12 KiB) Downloaded 115 times
User avatar
Gunroar:Cannon()
Party member
Posts: 601
Joined: Thu Dec 10, 2020 1:57 am

Re: My first successful Neural Network (AI)

Post by Gunroar:Cannon() »

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 :?
-It might look like nonsense :roll: but there's so much proof.
-Some more if you pls... :? .
It has to be real then, all that talk about the end :shock: .
-How to be saved :huh:
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests