Skip to content

Latest commit

 

History

History
50 lines (29 loc) · 1.72 KB

README.md

File metadata and controls

50 lines (29 loc) · 1.72 KB

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