Skip to content

A Connect Four AI bot that utilizes Monte Carlo Tree Search to determine winning moves!

Notifications You must be signed in to change notification settings

SotaNakajima/E4-4U

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

E4-4U

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

How this all works:

  1. 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.

  2. E4-4U takes a screenshot of the board (using pyscreenshot) based on those two input coordinates.

  3. Then, it processes the screenshot into an initial game state.

capture-initial-state-demo

The terminal window outputs:

Initial state:

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . x . . .

Initial game is enemy turn (enemy = 'X')

Now, that our initial state is set up,

  1. Our bot determines your next best move based on its MCTS algorithm and performs it automatically (using pyautogui to take control of the mouse).

perform-move-demo

The terminal window outputs: "E4-4U goes: (3, 1)".

Your next best move is (3, 1) (4th column from the left, 2nd row from the bottom) and E4-4U automatically performs it.

  1. Steps 2-4 are repeated until the game is over and you've won!

you-win

Full Demo:

https://youtu.be/iJY4uZ4lyKI

To run:

Install packages:

pip install -r requirements.txt

Start Connect Four Game online

We like https://papergames.io/en/connect4

Start the bot on your turn!

python e4_4u.py

WIN!

Sit back, relax, and watch our bot achieve victory!

About

A Connect Four AI bot that utilizes Monte Carlo Tree Search to determine winning moves!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages