Connect Four is a two-player board game in which the players alternately drop colored disks into a seven-column, six-row vertically suspended grid.
The objective of the game is to connect four same-colored disks in a row, column, or diagonal before your opponent does. The program prompts two players to drop a red or yellow disk alternately. Whenever a disk is dropped, the program redisplays the board on the console and determines the status of the game (win, draw, or continue).
The following program enables two players to place red and yellow discs in turn. To place a disk, the player needs to click on an available cell. An available cell is unoccupied and whose downward neighbor is occupied. The program flashes the four winning cells if a player wins and reports no winners if all cells are occupied with no winners.
The following program lets a user play with the computer. The program lets the user make a move first, followed by a move by the computer.