Connect Four
Pure Logic in the Terminal
Connect IV was developed as a technical and academic challenge during my studies at "Parthenope" University. Originally conceived as an exercise in memory management using C, the project evolved into an advanced study of game algorithms. The primary objective was to implement a competitive opponent utilizing the Minimax algorithm with Alpha-Beta pruning, demonstrating that gameplay depth stems from robust logic and optimized code rather than complex graphics engines.
Technical Stack: Pure C and Memory Management
The development of Connect IV required strict manual memory management; every malloc operation was carefully paired with a free to prevent memory leaks—a critical requirement for continuous applications. For the user interface, the ncurses library was utilized to render grids and colors directly within the terminal, ensuring a minimalist aesthetic and high-performance execution across macOS and Linux environments.
Artificial Intelligence Integration
The core of the opponent's logic is the Minimax algorithm, which evaluates the tree of possible future moves under the assumption of optimal play from the human player. To optimize computational efficiency, Alpha-Beta pruning was implemented. This optimization allows the system to eagerly discard disadvantageous branches, enabling deeper move calculations in real time without sacrificing performance.
References
Here is the source code for the project:
https://github.com/kairosci/connect-iv