A self-learning connect-4 game with a simple GUI. I used the blog on reinforcement learning to come up with my Q-Learning solution. The blog provides an excellent step-by-step approach to implement a solution using RL.
Connect-4 has a huge state space that renders Q-Learning ineffective. An approach using Deep Q-Learning will make a better self-learning AI agent for the game.
Figure 1 - AI agent (Yellow) playing against a human (Red)
- Install Python3, and the necessary libraries: (if not already installed)
sudo apt install python3
sudo apt install python3-pip
pip3 install numpy pygame
- Check if your system successfully installed all the dependencies
- Open terminal using Ctrl+Alt+T and enter python3
- The terminal should now present a new area represented by >>> to enter python commands
- Now use the following commands to check libraries: (Exit python window using Ctrl+Z if an error pops up while running the below commands)
import numpy
import pygame
- Using the terminal, clone this repository and go into the project directory, and run:
git clone https://github.com/urastogi885/connect-4-if-you-can
cd connect-4-if-you-can
python3 connect_4.py