Python + PyTorch + Pygame Reinforcement Learning – Train an AI to Play Snake
340,681
Published 2022-04-25
💻 Code: github.com/python-engineer/snake-ai-pytorch
✏️ Course developed by Python Engineer. Check out his YouTube channel: / @patloeber
🎨 Art by Rachel: rachel.likespizza.com/
⭐️ Course Contents ⭐️
⌨️ (0:00:00) Part 1: Basics of Reinforcement Learning and Deep Q Learning
⌨️ (0:17:22) Part 2: Setup environment and implement snake game
⌨️ (0:40:07) Part 3: Implement agent to control game
⌨️ (1:10:59) Part 4: Create and train neural network
🎉 Thanks to our Champion and Sponsor supporters:
👾 Raymond Odero
👾 Agustín Kussrow
👾 aldo ferretti
👾 Otis Morgan
👾 DeezMaster
--
Learn to code for free and get a developer job: www.freecodecamp.org/
Read hundreds of articles on programming: freecodecamp.org/news
All Comments (21)
-
Thanks for the awesome video! Really fun to see agent improving during the games.
-
Thank you so much for this tutorial. I have always wanted to introduce snake with ML. and now looking forward to learning more about pytorch
-
I’ve always wanted to do this, thanks alot for the tutorial
-
Excited to try this!
-
I did it!!! Thanks for showing this.
-
Super great video! I run it and after more than 2000 games it seems that the average score reached a plateau of 30. It Avoids boundaries very well. But it hit itself when the tail is too long. But this movement should be predicted before.
-
Very cool video! Highly useful!
-
Watched the first 4 mins and the game and the learning process is fantastic! 🎉 Will go on it with the rest hopefully soon.
-
Awesome, so hard to find that type of explanation of dqn. All clear, great balance between theory and coding part for beginners in rl.
-
That is so smooth bro, thanks
-
Always very high quality videos when I just need it :) Thanks a lot! Looking forward to finish the video 😎
-
A video as valuable as a playbook👍🏻👍🏻👍🏻
-
Very interesting tutorial. I was familiar with Snake code implementations, Tensorflow basics and RL principles and I could follow along. For some reason the plot doesn't appear, and I only get a small blank window where the plot should be. Probably some bug while typing the code down. Other than that everything works for me. Thank you very much!
-
Really interesting course !
-
A nice video. My only critique is that the presenter kept writing code for almost an hour without running it. That's not giving a good example.
-
Thanks for this video, I have solved all my doubts
-
Hello! Is there a way to save the state of the neural model? So I can load later a trained enemy AI, ready for being the player opponent? Thank you for the video!
-
Following this since I wanna make a pygame project of mine that I poured a lot of time into and have no idea what to make the game about play itself. Wish me luck.
-
how to perform UCB, optimal initial values and dynamic programming approaches in this model?
-
Thanks for freeCodeCamp for making this possible.