Python · NumPy · Pygame · Minimax · Alpha-beta pruning
A local Connect Four game with a computer opponent. A NumPy board stores the position, a heuristic scores candidate windows, and a depth-three minimax search chooses the computer’s move.
- Board modeling and detection of horizontal, vertical, and diagonal wins.
- Alternating game-tree search with alpha-beta pruning.
- A Pygame interface separated from importable, testable game logic.
| Read | Use it for |
|---|---|
| Project walkthrough | Purpose, workflow, repository map, and a concrete example |
| Code and artifact reference | Important files, functions, classes, and their responsibilities |
| Development guide | Setup, configuration, commands, tests, and remaining limitations |
Use Python 3.11 or 3.12 in a virtual environment.
python -m pip install -r requirements.txt
python connect_4.py
python -m unittest discover -s tests -vFive unit tests pass for game rules, tactical choices, draws, invalid columns, and board nonmutation. The Pygame interface also launched and closed using an SDL dummy display. Human interaction on a desktop and competitive AI strength have not been benchmarked. This is search-based game AI, not a trained model.
Original demonstration is retained for historical context.
GitHub profile · Portfolio · Earlier README
The earlier README is preserved as historical context; the guides above describe this branch's implementation.