Why waste time playing video games when you can train an AI to do it for you? Ok, maybe playing yourself is more fun but training an AI can be more educational.

We just published a course on the freeCodeCamp.org YouTube channel that will teach you the basics of reinforcement learning by showing you how to teach an AI to play a snake game.

Reinforcement learning is a type of machine learning that enables an agent to learn in an environment by trial and error using feedback from its own actions and experiences.

First you will create the game using Python and Pygame. Then you will create and train a neural network using PyTorch that can play the game better than most humans.

Patrick Loeber, also known as Python Engineer, created this course. He has created many popular courses related to Python and machine learning.

The girl and snake art for this course were created by Rachel Likes Pizza.

Here is what is what you will do in this four-part course:

  • Learn the basics of Reinforcement Learning and Deep Q Learning
  • Setup the environment and implement a snake game
  • Implement an agent to control the game
  • Create and train a neural network to play the game

Watch the full course below or on the freeCodeCamp.org YouTube channel (2-hour watch).