A classic Connect Four game implementation with both text-based and graphical interfaces. The game lets you play against a computer AI that uses various strategies to make its moves.
- Play Connect Four against the computer
- Both text-based and SDL graphical interfaces
- Computer AI with strategic moves
- Modular C code for easy maintenance and extension
To build the SDL version, you'll need:
- C compiler (gcc or clang)
- SDL2 library
- SDL2_ttf library
On Windows:
- Download and install MinGW with SDL2 and SDL2_ttf libraries
- Follow the on-screen instructions
- Choose a column (0-6) to drop your piece
- Try to connect four of your pieces in a row, column, or diagonal before the computer does
- Click on a column to drop your piece
- You can also use number keys 0-6 to select columns
- Press ESC to exit the game
- Click anywhere after a game ends to start a new game
- Mouse Click: Drop a piece in the selected column
- Number Keys (0-6): Drop a piece in the corresponding column
- ESC: Exit the game
main.c: Entry point for text-based gamesdl_ui.c: SDL-based graphical interfaceboard.c/h: Board representation and operationsgame.c/h: Game logic and win detectionai.c/h: Computer AI strategy
You can modify the game in various ways:
- Adjust board dimensions in
board.h - Add new AI strategies in
ai.c - Future ideas could include: multiplayer, difficulty levels, sound effects
This project is released under the MIT License.
- Original code by Nikolaos Rotas
- SDL2 library: https://www.libsdl.org/
- SDL2_ttf library: https://github.com/libsdl-org/SDL_ttf