Python Pong AI Tutorial - Using NEAT

  Рет қаралды 106,582

Tech With Tim

Tech With Tim

Күн бұрын

Пікірлер: 124
@yubinxie4475
@yubinxie4475 4 күн бұрын
Although I must agree the topic discussed here is not beginner friendly, the way you explained a lot of the details and even went back one point to reiterate what you wrote for the train ai script was extremely well done. Thank you for the tutorial!
@krit6847
@krit6847 2 жыл бұрын
Im addicted to your tutorials, keep it up Tim!
@kamakura9722
@kamakura9722 Жыл бұрын
Sammeee
@Djellowman
@Djellowman Жыл бұрын
To those implementing this: you will need the x and y velocity of the ball too if you use a ball speedup-mechanic (like i do) where the ball moves faster than the paddles. then it's not enough to simply keep the paddle y the same as the ball y, you need the velocity so it can predict where the ball will go.
@Djellowman
@Djellowman Жыл бұрын
Coming back to this, it turns out genetic algorithms get stuck in a local minimum, with absolutely no way to get out of it. This minimum means that the model only learns to keep the paddle at the same height as the ball... So it's seemingly impossible to train a competent AI for Pong using a genetic algorithm if the above strategy stops working once the ball speeds up. Perhaps reinforcement learning would work, but i don't see how that would get out of the same local minimum.
@Seedx
@Seedx Жыл бұрын
@@Djellowmanweird, genetic algorithms are supposed to avoid local minimums. Is the speciation implemented correctly?
@Apify
@Apify 2 жыл бұрын
Happy to support Tim's videos - keep up the great work! :)
@astrovation3281
@astrovation3281 2 жыл бұрын
Thank you so much! I've never done anything with AI before, so even if this is hard for me it'll probably be very educational.
@jamieharper5665
@jamieharper5665 Жыл бұрын
Amazing video thank you! Had an issue with the data printing but then realised I was just being impatient and needed to wait lol. I can't tell you how useful this was as an introduction to neural networks for me 😁
@fhtagn20
@fhtagn20 2 жыл бұрын
Your tutorials have really helped me improve my programming skills Tim in a way I can't put in words. Thank you so much!
@ShubhAgarwal__
@ShubhAgarwal__ 2 жыл бұрын
Bro I was looking some tutorial to make a pong ai using python at 2 days later ur video is here love it and don't know how you know what the views want thnx alot
@TomDoesTech
@TomDoesTech 2 жыл бұрын
This is so cool! Awesome tutorial
@kiat4797
@kiat4797 2 жыл бұрын
love ur videos tim . i have been Following u for a long time ( probably 3 years ). i love how u're explaining various concepts clearly and smoothly and i would love to see u creating a ray casting engine or ray tracing engine in pygame . a lot of fun math ( linear algebra , geometry ... ) and some cool physics concepts to discover while coding it
@Nimnimpac
@Nimnimpac 2 жыл бұрын
If I am correct in around 49:50 you lower later genomes fitness. Lets say we have 3 genomes. We set genome1 fitness to 0 in first for loop then in second for loop test it against genome2 and genome3. After this genome1 has fitness 10, genome2 fitness 4 and genome3 fitness 6. The we go to genome2 and set it fitness to 0 but due to second for loop " in genomes[i+1:]" genome2 wont play against genome1 now only against genome3 so it will have lower fitness.
@HcmfWice
@HcmfWice 2 жыл бұрын
Yeah, I’ve noticed this as well. Also, genome1 only plays on the left side (and the last genome only plays on the right), while all the other genomes play on both side. A simple fix would be to iterate over the whole range in both the outer and inner loop, and in the inner loop make sure that the two IDs are different (if you don’t want the genomes to play against themselves). It really says something about the robustness of evolutionary genetic algorythms that it still produced a genome that plays well.
@ezb_ai
@ezb_ai 2 жыл бұрын
Liked and subscribed. Thank u so much for the knowledge, kind sir.
@samurai-capybara
@samurai-capybara 2 жыл бұрын
Love your videos! I'm going to use what I've learned from this and your Flappy Birds series to build an AI for a 2D fighting game.... taking me one step closer to Skynet
@eitanshpigler8072
@eitanshpigler8072 2 жыл бұрын
Hey Tim, thanks for the great video. Would love to see more cool things with AI and NEAT
@lorenzofiore7438
@lorenzofiore7438 4 ай бұрын
Just finished the video. I can't wait to actually start writing some code. Firstly on pong and next on some random game i'll find. The cool part about neural networks is that they do all of the hard work for you by optimizing the output without knowing what it is going to be used for. They just adjust weights and biases waiting for a treat 😂. Unfortunally for genetic algorithms they are going to die without being rewarded 😢😂. Thank you for the video.
@mindofpaul9543
@mindofpaul9543 Жыл бұрын
This was an awesome tutorial and a great way to dip my toes into learning machine learning. Thanks for the video!
@xucr0516
@xucr0516 2 жыл бұрын
Love ur vids. Because of you i am getting better and better in python. I just started like 5 days ago and i made an own made command prompt!
@krishnakeshari4858
@krishnakeshari4858 2 жыл бұрын
Rly
@xucr0516
@xucr0516 2 жыл бұрын
@Shinero Oh man
@gidartsproduction5439
@gidartsproduction5439 2 жыл бұрын
Thanks for the tutorial, I have been waiting for this...
@Tafawaq
@Tafawaq 2 жыл бұрын
Tim is such an amazing teacher , how can i support this channel financially?? love from syria
@goranjosic
@goranjosic 2 жыл бұрын
I'm working on my first NEAT AI project, and this tutorial is very helpful because the documentation is quite scarce. Before this video, I watched a NEAT AI video by sentdex channel, and it's quite bad compared to this one - his video is literally a copied example from the documentation, without any new explanations - it's just not worth watching, it's better to read the documentation, than to watch his video - my experience. Overall, good tutorial!
@xGino_n
@xGino_n 2 жыл бұрын
thank you so much!, was hard to find a cool & easily understandable tutorial.
@namashaggarwal7430
@namashaggarwal7430 2 жыл бұрын
Awesome video, Could you please make a series of DeepFakes technology using Python from beginner to Advanced with all concepts and it's mechanism. Thanks alot, I follow all your videos and really appreciate your hard work. 加油 ❤️
@heelercs
@heelercs 2 жыл бұрын
I have a feeling that he won't due to the ethical concerns.
@namashaggarwal7430
@namashaggarwal7430 2 жыл бұрын
@@heelercs don't know man, but this technology is kinda cool and futuristic. If we could master it and combine with the 3D modelling and printing to create human looking AI robots, then the world could turn into a Terminator
@heelercs
@heelercs 2 жыл бұрын
@@namashaggarwal7430 Agreed, it is really cool technology. Unfortunately it's almost always seen as a harmful technology (for now). I doubt Tech With Tim would want to publicly associate with something that's almost always associated with pornography.
@namashaggarwal7430
@namashaggarwal7430 2 жыл бұрын
@@heelercs every technology in the world has 2 sides , one is positive and second is negative. To exemplify, nuclear technology can be used for destruction of a nation using nuclear bomb but on the other side, the same thing can be used as an excellent carbonless energy source for the construction of the humankind. We must need to make certain rules and protocols for each and everything to keep a positive balance. It all depends on us, how we make use of it.
@heelercs
@heelercs 2 жыл бұрын
@@namashaggarwal7430 I never disagreed with that. However, just because two sides exist doesn't mean they hold equal weight. To use your own example, surely you don't think that the positives and negatives of nuclear bomb technology is equal? There's definitely much more potential negative harm than positive harm. Since we're going to extremes, gas chambers are another example. Surely you don't think the positive and negative are equivalent, right? So my point still stands.
@jantonisito
@jantonisito 10 ай бұрын
Maybe you could do part to and analyze how those NNs evolve. The key point for me was that some randomly generated set of connections will produce some output (three numbers) . We CHOOSE to interpret these numbers as movement of the paddles - order of stay/up/down is arbitrary. Once we chose some interpretation we apply it to paddle movements and we asses if given NN (given genome) actually makes good decisions (is more fit). What is completely elusive for me is how they make a decision to merge network topologies - without some actual analysis what changes in structure could be responsible for performance improvement - how do you pick up what to merge? Either way very good tutorial - thanks! PS. If your generation runs slow definitely turn of screen rendition during training - program runs ~30 times faster. Also I found out that limiting exchanges (hits) to less than a suggested 100 speeds up hitting the target fitness. With 70 limit I hit 430 fitness in 18 generations.
@Global_Reality-bcn
@Global_Reality-bcn Жыл бұрын
Thank you a lot Tim, I really appreciate your work, the way you explain is phenomenal, I am a fan of your programming videos please keep them coming. kind regards,
@HypnosisBear
@HypnosisBear 2 жыл бұрын
Great tutorial Tim.
@karlbooklover
@karlbooklover 2 жыл бұрын
Saw this coming on your GitHub so I activated notifications here 🌚
@Ghazalli
@Ghazalli 2 жыл бұрын
Thank you, it was great, please continue the same path and take more NEAT videos for us 👌🏽🙏🏽
@anthonydawson9700
@anthonydawson9700 Жыл бұрын
Very good and a lot of hard work! Thanks 🙂
@maspot7718
@maspot7718 2 жыл бұрын
Love the way you explain things
@jeremyheng8573
@jeremyheng8573 2 жыл бұрын
good explanation! wish to watch more video about reinforcement leaning in python
@filippostazi4502
@filippostazi4502 2 жыл бұрын
you are the number one, fantastic video
@teaqllabs6174
@teaqllabs6174 2 жыл бұрын
Hi Tim! My name is Ian and I am a 16 year old developer, right now I am working on a compiled multipurpose programming language from scratch in C and I was wondering if you could maybe check it out. That would really make my whole day. But if not, I totally understand. -Ian
@Ta_3-k8n
@Ta_3-k8n 2 жыл бұрын
Thank you so much Tim, this is so valuable, could you make another one on AI plays Snake game that would so helpful.
@Djellowman
@Djellowman Жыл бұрын
Protip for viewers: use multiprocessing to train the model use all your cores in parallel
@Djellowman
@Djellowman Жыл бұрын
Using
@guillaumerousseau9549
@guillaumerousseau9549 Жыл бұрын
Impressive work, thanks a lot for sharing this
@samuelbouhanik1004
@samuelbouhanik1004 5 ай бұрын
this is an awesome video, thank man
@AlexDevQa
@AlexDevQa 2 жыл бұрын
Tim - the best!
@nobertwekesa8923
@nobertwekesa8923 2 жыл бұрын
Nice vid. Had to stop everything to watch this👍
@drydenstewartenterprises
@drydenstewartenterprises 2 жыл бұрын
Hey Tim, Thanks for the video! I was wondering though, because you used NEAT with flappy bird, and now with pong, is neat used just for games? I've been learning Python through you and Sentex and neuralnines videos for the past 2 years and I have learned a lot but I still have a long way to go, I am interested in building some of my own small robots and I am wondering if you would ever work on a series about incorporating computer vision with a voice assistant and some form of AI (maybe neat?) so my little robots can recognize objects and people, and tell you that it has recognized those objects or people?
@ravenblackspike
@ravenblackspike 2 жыл бұрын
NEAT would probably not be useful in that particular use case. You would be better served by a couple of discrete models with code that passes your inputs to the models. Something like the below. 1) Computer Vision model for object recognition. 2) Speach recognition model, TTS model for the voice commands and output. 3) Whatever code you would need to handle moving the robot/passing inputs to your models.
@hubowenstudent3599
@hubowenstudent3599 2 жыл бұрын
A great CV model would be YOLOv5
@arnavgupta2400
@arnavgupta2400 Жыл бұрын
Thanks!
@KhazaeeTech
@KhazaeeTech 2 жыл бұрын
The video was very useful. Please use neat more in the videos. I watch almost all of your videos, but AI is very useful. Please provide a complete neat tutorial.👏🏽
@marcusberge8378
@marcusberge8378 2 жыл бұрын
Really good video!
@hazelNoFake
@hazelNoFake 2 жыл бұрын
I am not going to do some beginner coder stuff. I'm jumping right into this (like people who jump from an easy demon to an extreme demon)
@aowowow-no1xe
@aowowow-no1xe 8 ай бұрын
Note: You can turn off the pygame drawing to speed things up
@___OmerAJ___
@___OmerAJ___ Жыл бұрын
❤❤❤
@bellpepper_red
@bellpepper_red Жыл бұрын
thanks for the epic project Tim! I had 0 knowledge of ML but I still had fun following along, and learned many things on the way. Knowledge_of_ML +=1
@lawson1310
@lawson1310 2 жыл бұрын
Woww, a dream come true 😍
@manfredsteyn
@manfredsteyn 2 жыл бұрын
Fantastic work. Impeccable teaching abilities. Learning a lot from your videos. Thank You!
@georgenjeru9627
@georgenjeru9627 2 жыл бұрын
Daamn,. How did you become so great in programming..?.
@universecode1101
@universecode1101 2 жыл бұрын
Difficult but cool 👍🏻
@Lahmeinthehouse
@Lahmeinthehouse 2 жыл бұрын
The way you say VIDEO 😂😂 it’s your signature !!
@ethitlan
@ethitlan 2 жыл бұрын
Hey Tim, I have a question. Does the frame rate you train it with affect its performance? I've been training it with no frame rate cap for a long a time until I played against it and it wasn't as good as I hoped. So then I changed the frame rate and (although it was humanly impossible for me to play the game) the AI did MUCH better at receiving the ball. What do you think?
@Djellowman
@Djellowman Жыл бұрын
good question. yes it does affect the performance, as it gets more input and actions per second if you have a higher tickrate. But i'm surprised to hear it's a big difference.
@Djellowman
@Djellowman Жыл бұрын
actually, if your tickrate is tied to the framerate, it shouldn't matter. It means the game speeds up as your tickrate increases. So actually, no it should be identical during training and playing against you.
@ethitlan
@ethitlan Жыл бұрын
@@Djellowman oooh then perhaps my tickrate was different. Thanks for answering Tim!
@BentleyKingToebeansOwenRhett
@BentleyKingToebeansOwenRhett 5 ай бұрын
Pretty neat
@online.python.dersim
@online.python.dersim Жыл бұрын
thanks clear explanation
@babitabarman2582
@babitabarman2582 2 жыл бұрын
Hey Tim when does new time out with Tim podcast comming
@nicom9853
@nicom9853 2 жыл бұрын
Huh, very interesting! I'm guessing this can be used on any kind of supervised learning as well?
@ChrisJames-tf8yw
@ChrisJames-tf8yw 8 ай бұрын
Awesome video. Now can the AI be created that moves the ball x,y position. The future should be code-less apps. I want to try make a Python training that would make the AI generate the ball x,y coordinates for the game. But could this be done without coding as well? Could an AI be trained to watch a pong game and then be used to train the AI to control the ball x,y?
@Gunsi-kb2xq
@Gunsi-kb2xq 2 жыл бұрын
for me it creates only 1 ID per generation... is this OK? Tried your code as well but aways only 1 ID after every generation...
@FireFly969
@FireFly969 2 жыл бұрын
Thank you
@soul-igion7221
@soul-igion7221 2 жыл бұрын
So, I am a neophyte for Pycharm & Tensorflow ,,, May i please be provided with "Tutorial videos on how to run models in "PYCHARM" which are listed on Tensorflow website. I tried to run Image Classification Model but it's running till "Visualize Training Results" in PYCHARM & after that it's not showing any result for "Overfitting, DataAugmentaion, And Code parts". I tried to search but didn't found any relevant result for issue. If this doubt is not clear to me , I can't start my Tensorflow Developer Certificate Exam.
@iancardona3719
@iancardona3719 Жыл бұрын
amazing tutorial tim! tho i'm having trouble why am I getting negative values in my population average fitness; what could be the problem?
@danilotrix
@danilotrix 2 жыл бұрын
This was amazing. Thanks so much. 1 question. What about rewards? You didn’t mention it or I missed it. How do they learn the right movement to do? Thanks
@NinjaTxGaming
@NinjaTxGaming 2 жыл бұрын
Reward is the fitness variable. Tim set the reward to the number of balls hit in total throughout all the games.
@Djellowman
@Djellowman Жыл бұрын
it's not reinforcement learning
@visiblecode5238
@visiblecode5238 2 жыл бұрын
Nice
@visiblecode5238
@visiblecode5238 2 жыл бұрын
@♜ Pinned by Tech With Tim shut up bot
@ninek1902
@ninek1902 2 жыл бұрын
Hey Tim, I have a question about the oscilating best fitnesses... How is it possible for best fitness to drop in comparison to last generation if there is elitism involved? In your config the elitism parameter is set to 2, which means 2 of the most fit individuals from each species will get pasted in the next generation (according to neat-python docs), thus the algorithm is not supposed to score lower than their previous score...
@mmdrlolfr2612
@mmdrlolfr2612 2 жыл бұрын
I think it's because if the first genome gets a mutation, his fitness can decrease and if nobody has exceeded the previous best fitness, the global fitness will just decrease. Or maybe it's because the first direction of the ball in pong in random and maybe the first genome got an extremely good luck and that didn't happen later.
@tcgvsocg1458
@tcgvsocg1458 2 жыл бұрын
You hav to show how can remove ia for player to play against and generate differente type of ia (norma,l hard, easy
@frosbee6344
@frosbee6344 2 жыл бұрын
Hi thanks for your work. Can This also work in Jupiter notebook?
@gzbin365
@gzbin365 2 жыл бұрын
cool!
@Kennethlumor
@Kennethlumor 2 жыл бұрын
Please and please I request you make video on how to use multiple databases in flask
@0Clappy
@0Clappy 2 жыл бұрын
Please update the code on Github to the finalized file, I attempted to follow along step by step but too many errors occurred and I ended up with a frankenstein mashup of code.
@reyhane2266
@reyhane2266 6 ай бұрын
I've been trying to implement this, so far I've had 197 generations ran and the best fitness till now was 23, is this normal? is it supposed to take that long?
@SkyFly19853
@SkyFly19853 2 жыл бұрын
How about A.I. tutorial for chess game in Python?
@TheTheuhh
@TheTheuhh 2 жыл бұрын
Can you teach us how to create a forum website?
@nobbytho
@nobbytho 2 жыл бұрын
your flappy bird video is taken down?
@MachineLearner-p7k
@MachineLearner-p7k 3 ай бұрын
Can anybody tell me whether this will be good project that to be kept in our resume ??
@PP-tc1zp
@PP-tc1zp 2 жыл бұрын
Hi, thank you. It is very interesting. I made simple modification wchich allow play with player and check ai in 1 game session with dynamic switch between player and ai. If you want I can put this on github. So who is better you or ai ;)
@0Clappy
@0Clappy 2 жыл бұрын
What program are you using to draw?
@leonardsmith9870
@leonardsmith9870 2 жыл бұрын
Wow, this is neat! Lol.
@karma_senpai
@karma_senpai 2 жыл бұрын
Most of The People get bored when doing there favorites thing sometimes. I have a question that did you get bored doing programming sometimes.
@mayman8415
@mayman8415 2 жыл бұрын
pls make a vid on burnout
@stefanlin5086
@stefanlin5086 2 жыл бұрын
whn I run test_ai the ai dosent move at all
@stefanlin5086
@stefanlin5086 2 жыл бұрын
@♜ Pinned by Tech With Tim dont worry got it fixed
@pravachanpatra4012
@pravachanpatra4012 2 жыл бұрын
1:05:00
@rayankhan12
@rayankhan12 2 жыл бұрын
Thanks 😊 :) (I was wondering if it's possible to write a Python code that would automatically send birthday messages to my WhatsApp contacts?)
@ElPsyVega
@ElPsyVega Жыл бұрын
17:20 hehe
@lrnzdc7199
@lrnzdc7199 2 жыл бұрын
Please make a video on licenses, no one talks about them! There isn't a decent video to watch.
@codesaif8075
@codesaif8075 2 жыл бұрын
Hey Tim, Can you Explain how can i make logic in programming?, like when i start wrting code i have no idea what to write in first line i get so confused, How do you do it?, how can be good in coding like you?
@BlhJ400
@BlhJ400 2 жыл бұрын
Hey thanks so much for the informations, I am just wandering JavaScript or python ? Someone says python slow others says it has many libraries but I don't get it . Everything is confusing and there's no clear path to start, I really want your help, thanks 🙏 you are the best
@sintax9286
@sintax9286 2 жыл бұрын
holy shitfuck, this is amazing * _ *
@karamsabbagh7465
@karamsabbagh7465 2 жыл бұрын
What's the point of making an AI for ping pong for this kind of games you van just make a simple bot that's impossible to loose and it's faster, easier, no need to wait the AI to learn, You can simply make the paddle follow the y position of the ball and you can make some modernization and let it predict the ball balance of the walls and here you go easy and so simple !
@TechWithTim
@TechWithTim 2 жыл бұрын
To learn how to train ais to play games and examine the behaviour!
@karamsabbagh7465
@karamsabbagh7465 2 жыл бұрын
@@TechWithTim Ah yeah got it but I think working on a harder game would be good and reasonable like if I saw your AI I would think it like a simple bot. But anyways I got it you want to start easy and learn then make something reasonable. And btw I really think that making an AI for snake is really good for multiple reasons (because making a snake AI with a snake(Python) is great XD).
@MnM_rulz
@MnM_rulz 2 жыл бұрын
Hey Tim, can you please teach how to download dlib and face_recognitiom PLEASE. Thank you
@MnM_rulz
@MnM_rulz 2 жыл бұрын
Please teach how to download face recognition
@DGHere12
@DGHere12 2 жыл бұрын
second
@coolguy7160
@coolguy7160 2 жыл бұрын
10th comment
@shalevforfor5550
@shalevforfor5550 9 ай бұрын
Just make a bot . You have a ball and make another one that go faster then him or a line that go and just when the second ball is > then the bot x so then just move to he's y no need an AI for this
@xidiffiyt7986
@xidiffiyt7986 6 ай бұрын
this is just about learning how to use ai
@walney2008
@walney2008 Жыл бұрын
please speak IA play game chess
@PP-tc1zp
@PP-tc1zp 2 жыл бұрын
Booster to improve performance, mutch faster: for genome_id2, genome2 in genomes[random.randrange(i+1):]:
@adityaraina7727
@adityaraina7727 Жыл бұрын
Thanks!
@shalevforfor5550
@shalevforfor5550 9 ай бұрын
Just make a bot . You have a ball and make another one that go faster then him or a line that go and just when the second ball is > then the bot x so then just move to he's y no need an AI for this
AI Teaches Itself to Play Flappy Bird - Using NEAT Python!
10:16
Tech With Tim
Рет қаралды 143 М.
Make Pong With Python!
1:12:42
Tech With Tim
Рет қаралды 118 М.
Players push long pins through a cardboard box attempting to pop the balloon!
00:31
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
NEAT Algorithm Visually Explained
18:07
David Schäfer
Рет қаралды 7 М.
Training an unbeatable AI in Trackmania
20:41
Yosh
Рет қаралды 14 МЛН
Planet Simulation In Python - Tutorial
1:00:02
Tech With Tim
Рет қаралды 509 М.
Snake learns with NEUROEVOLUTION (implementing NEAT from scratch in C++)
28:08
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 415 М.
NEAT - Introduction
21:27
Finn Eggers
Рет қаралды 85 М.
The Truth About Learning Python in 2024
9:38
Internet Made Coder
Рет қаралды 217 М.
Neuroevolution of Augmenting Topologies (NEAT)
13:39
Connor Shorten
Рет қаралды 41 М.
I programmed some creatures. They Evolved.
56:10
davidrandallmiller
Рет қаралды 4,2 МЛН