PyGame: Let’s beat the machine learning model
Today, this week we will be doing a fun activity as we always do but this time we will try to beat the machine learning model. Wait, what!!! Can it be possible?? I don’t know the answer to the question.😬 But this is the competition between us and the machine learning model. Let’s start setting things up.😁😎
After installing the requirements, we will be playing the game against the machine. Have you heard of the game FlappyBird Game? Flappy Bird game is similar to Mario forever game in which we have to fly the bird as far as we can without hitting a pipe. So I have created two versions of the game. One is the human version and the other is the machine learning model version. So we will install both versions on our machine.
The human version game is created using the Pygame. Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python programming language. To run the human version, navigate to the root folder. Type the following command.
The backend of the machine version is running on the deep learning model. There are three convolutional layers and two fully connected layers. Each layer uses ReLU activation, except the last one, which uses linear activation. The neural network outputs two values representing the player’s only possible actions: “Fly up” and “do nothing.” The input consists of four consecutive 84×84 black-and-white images. The neural network architecture is the same as DeepMind used in the paper Human-level control through deep reinforcement learning. To refer more, one can visit this article. To run the machine version, navigate to the root folder. Type the following command.
Keep running one side of the machine version and let’s play the human version game. See where we can beat the machine version game. I’ll deploy the code to the sandbox library public machine. So if you face trouble in running the game then you can book the public machine and enjoy playing the game. 🤙😎😋