Skip to content

technocrat13/Connect4Bot

Repository files navigation

Connect4 AI

Build pytest pylint

Python bot to play connect4, uses Q-Learning based on the Greedy Epsilon Bellman Equation.

https://youtube.com/shorts/njdJeu95p6s?si=jI39STsb80ijHa8h

Installation

  1. Unzip q_table_shelf.db.zip and place the three files in root.
  2. Install numpy
pip install numpy

Usage

  • To play a best of 3 against the AI:

     python connect4.py
  • To train the model:

     python train.py

    By default this will train the model for 60,000 episodes, the model in q_table_shelf.db has been trained for 200,000 episodes/10 hours.

Information

The gameboard is a 2D list and is represented in the following image, positions to drop a COIN are from 1 to 7, player one is 7, the AI is player two or 5. 0 represents an empty space.

gameboard image

References

About

python bot to play connect4 against

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published