connect4
Thriving Thriving Python PY
โ†‘ 56 ?
connect4 bymayanksingh/connect4

๐ŸŽฎ It is a two-player connection game in which the players first choose a color and then take turns dropping one colored disc from the top into a seven-column, six-row vertically suspended grid. The pieces fall straight down, occupying the lowest available space within the column, user wins by forming row of four of same color

HEALTH ? 100 / Healthy
// solo builder// hidden gem// legacy hero// fork magnet pythonpygamenumpyconnect-fourboard-game ?

// readme

Connect Four

Production-Grade Connect 4 Engine, Multi-Algorithm AI Suite & Headless Visualizer


๐Ÿ“– Overview

Connect 4 is a modernized, production-ready implementation of the classic vertical connection game, engineered for high performance, modularity, and algorithmic depth.

Originally conceived as a Pygame application by Mayank Singh, this repository integrates community PRs, academic research from Columbia University on Markov Decision Processes (MDPs), and production software engineering practices:

  • Decoupled Architecture: Domain rules, board state, AI engines, terminal CLI, and Pygame presentation are separated into dedicated modules under connect4/.
  • Multi-Modal AI Suite:
    • Random Agent: Uniform random sampling over legal open columns.
    • Heuristic Agent: Fast tactical 1-ply immediate win execution, threat blocking, and center preference.
    • Minimax Agent: Deep tree search with $\alpha\text{-}\beta$ pruning, center-first move ordering, and an Odd-Even strategy heuristic.
    • Dynamic Programming (MDP) Agent: Finite-horizon value iteration and exact linear system solving ($(I -โ€ฆ