Connect Four
Difficulty: Medium
In this challenge, you'll implement a simplified version of the classic Connect Four game. Two players take turns dropping disks into an array of columns, and the game announces the winner when four consecutive disks are aligned horizontally, vertically, or diagonally.
Requirements
Gameplay Mechanics
- Create a 5x7 grid for gameplay (5 columns).
- Allow players to drop disks into any column. A disk drops to the lowest available row in the selected column.
- Players take turns dropping disks.
Win Detection
- Detect four consecutive disks of the same player:
- Horizontally
- Vertically
- Diagonally (both directions)
- Display the winner's name when a player wins.
Edge Cases
- Prevent players from dropping a disk into a full column.
- If the board is completely filled and no player has won, declare a draw.
Above & Beyond
Once the core mechanics are complete, consider adding:
- Undo Last Move – Let players undo their last move.
- Custom Board Size – Allow different grid sizes (e.g., 6x5, 8x7).