Problem
Create a Connect 4 game on the client with changes reflected on the UI.
Requirements
- Build a 6 (rows) x 7 (cols) board.
- Two players, Blue and Red, alternate turns; one move per turn.
- The player selects a column (e.g. a button per column); the disc falls to the lowest empty row in that column.
- Win condition: 4 consecutive same-color discs horizontally, vertically, or diagonally.
- UI must update so a user can interact and see the board change.
+---+---+---+---+---+---+---+
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | <- column selectors
+---+---+---+---+---+---+---+
| . | . | . | . | . | . | . |
| . | . | . | . | . | . | . |
| . | . | . | . | . | . | . |
| . | . | . | . | . | . | . |
| . | R | . | B | . | . | . |
| B | R | B | R | . | . | . |
+---+---+---+---+---+---+---+ B = Blue, R = Red, . = Empty
Hints / Approach
- Board as
6 x 72D array. Dropping in columnc: scan from the bottom row up for the first empty cell. - Win check from the last placed disc
(r, c): count consecutive same color in all 4 directions (both ways) and check if total >= 4. - Track
currentPlayer,winner, and disable input after a win or full board (draw).