Building the Flappy Bird A.I. without LIBRARIES | Genetic Algorithm | Python/PyCharm

preview_player
Показать описание
Adding the Genetic Algorithm to Flappy Bird by building a Neural Network and Natural Selection Process from Scratch in Python & PyCharm! No Libraries are used!

◾◾◾◾◾ Timestamps ◾◾◾◾◾
00:00:00 | Introduction
00:01:48 | 1. Building an empty window
00:05:29 | 2. Adding the ground
00:07:43 | 3. Adding the pipes
00:14:49 | 4. Adding a player
00:18:28 | 5. Player movement, collisions, and gravity
00:24:58 | 6. Build a population of players
00:27:16 | 7. Neural Network (A.I. part 1)
00:50:16 | 8. Natural Selection (A.I. part 2)
01:20:16 | 9. Final Touches

◾◾◾◾◾ 🌎 Let's Connect! ◾◾◾◾◾

◾◾◾◾◾ Hashtags ◾◾◾◾◾
#neuralnetwork #machinelearning #artificialintelligence
Рекомендации по теме
Комментарии
Автор

Just to be clear: While I did use Pygame to build the game, the AI is coded entirely from scratch without any additional ML or AI libraries.

MaxRohowsky
Автор

You really deserve more subs/views. These vids are amazing. I haven't even finished this yet but learned so much so far 👍👍👍

raccoon_
Автор

I kid you not when I say I was trying to make a neural network from scratch using numpy like 5 days ago. The timing couldn’t have been better

cookiecrumbzi
Автор

Good video, I chose a different method of generating offspring though which proved more accurate (and also prevents 80% of them dying before even reaching the pipes after the first generation). Basically I cloned 1/3 of the new birds from the best bird in a species, then 1/3 cloned from the second best bird in a species, then 1/3 is "offspring" so I averaged the weights between the first and second best bird in a species and created new birds with those weights. All these birds were then put through the mutate() function which has a 80% chance of mutation. I'm still testing, but in only 9 generations (100 population), I've hit 5700+ lifespan. The birds do still struggle with going from low to high pipes, I think this has to do with the "cooldown" of the jump meaning it's not possible for birds to go from very low to very high as they can't jump that fast, I'll look at tweaking that next. UPDATE: changing if self.vel >= 3: to a smaller number in the player.py file fixes this issue. I used if self.vel >= 2: instead and it seems a lot better, at least it's not impossible like it is with 3. My new best lifespan is 21387 at only 3 generations. I'm planning on testing further with making the mutation rate 100%, but saving the best bird from each species. I found this algorithmn online somewhere.

I also added text on the window to show generation, species, players, current lifespan, and best lifespan. I'm considering adding textboxes to show the current best weights as well, but still not sure.

EDIT: Best now is lifespan over 60000

lucanastral
Автор

Hi, this was an amazing video. Though I really wished you made the functions in order of how they were needed instead of completing one file after another. But still, very good video!

I really want to ask how you were able to implement such a complex algorithm from scratch. Where did you learn this from? Have you implemented this before in other projects? Also, your code structure was really neat, how did you come up with that?

Ayush-szys
Автор

"Without using any libraries"

*Proceeds to reference PyGame*
Lol. Great video, and this is the only good tutorial that I have found, that shows you how to code the neural network from scratch. Thank you!

LIGHTBULBCODING
Автор

yes bro deserve more views yt algorth agree

chillbeast_sheno
Автор

if we make more of champion babies instead of one, the algorithm shouldn't be faster ?

felix_md
Автор

I have an error at the end of part 1 where when the ai stops flapping it drops and doesn’t try to flap again should I be concerned or should I just keep going

rafedagamer
Автор

Nice video, really well done.

But I'm curious if you know how hard it would to do this without pygame

oisinforde
Автор

Hi love you video, what is the software you use to draw image thx

zheli
Автор

It works great, but even when learned, players can't jump high enough to get through the pipes at the top. How to make it pass through all pipes?

tomasznieznane
Автор

why does the pipes blink when the one juste before is deleted ?

felix_md
welcome to shbcf.ru