Python bot to play connect4, uses Q-Learning based on the Greedy Epsilon Bellman Equation.
https://youtube.com/shorts/njdJeu95p6s?si=jI39STsb80ijHa8h
- Unzip
q_table_shelf.db.zip
and place the three files in root. - Install
numpy
pip install numpy
-
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.
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.