E4-4U is a Python AI bot that autonomously plays Connect 4 games online for you.
This bot has won 1st place in multiple daily/weekly leaderboards for various sites online against real players!
Its decisions are based on a Monte Carlo Tree Search algorithm which simulates game outcomes based on your available moves and uses those outcomes to determine your next best move.
Note: Windows Only
-
The user runs the program and is prompted to click on the upper left and bottom right corners of the game board when it is their first turn.
-
E4-4U takes a screenshot of the board (using pyscreenshot) based on those two input coordinates.
-
Then, it processes the screenshot into an initial game state.
Initial state:
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . x . . .
Initial game is enemy turn (enemy = 'X')
Now, that our initial state is set up,
- Our bot determines your next best move based on its MCTS algorithm and performs it automatically (using pyautogui to take control of the mouse).
Your next best move is (3, 1) (4th column from the left, 2nd row from the bottom) and E4-4U automatically performs it.
- Steps 2-4 are repeated until the game is over and you've won!
pip install -r requirements.txt
We like https://papergames.io/en/connect4
python e4_4u.py
Sit back, relax, and watch our bot achieve victory!