This is an implementation of John Tromp's very efficient Connect Four board logic code (read more about it here), coupled with a Monte Carlo Tree Search (MCTS) "AI" and a CLI for playing against it in the terminal.
The Monte Carlo Tree Search uses the UCT algorithm in the selection phase, and uniformly random moves in the simulation phase. It rebuilds the whole tree on each move, and doesn't employ any parallelization strategies while searching. Even so, it plays very well!
To play against it in your browser, right now, you can use Gitpod to launch a temporary dev environment containing a terminal with the CLI running by clicking on the badge above.
-
Make sure you have Elixir and Erlang installed (you can find the required versions in the
.tool-versions
file) -
Clone the repo
git clone https://github.com/rjdellecese/connect_four.git cd connect_four
-
From the root of the project, download the dependencies
mix deps.get
Run the tests with
mix test
To play against the MCTS AI, cd
into the CLI app, build the escript executable, and then run it
cd apps/cli
mix escript.build
./cli
If you have any questions about how any of this works, please feel free to open an issue and I'll be happy to respond!