Back to Arcade

Connect Four AI

Pro Canvas Board

Connect Four and Tic-Tac-Toe against a minimax opponent with alpha-beta pruning. Choose how deep it searches, from careless to genuinely sharp -- the difficulty is real search depth, not artificial mistakes. A readout shows how many positions were examined with pruning and without, so you can watch it discard over 90% of the tree without changing its answer. Tic-Tac-Toe is searched to the end of the game and cannot be beaten.

Controls

Mouse: Click a column to drop a piece; in Tic-Tac-Toe click a square. Touch: Tap a column or square. Use the selectors to switch game and search depth. You always move first.

This game is built in Lesson 3.7. View the curriculum