Java Logo

Connect 4 game

Connect 4 game.	

You will get a 100 if you can create this program
	with using only Pseudocode.
If you have a copy of the complete program,
	You will get a grade of 70.

Here's a basic Python program for a console-based Connect Four game. The game is played in a 6x7 grid, where players take turns dropping pieces into columns to form four in a row horizontally, vertically, or diagonally. This code includes functions to create the board, place pieces, and check for win conditions. Here's a basic Python program for a console based Connect Four game. The game is played in a 6x7 grid, where players take turns dropping pieces into columns to form four in a row horizontally, vertically, or diagonally. How to Play: 1. Start the game by running the code. 2. Players take turns choosing a column to drop their piece into by entering a number from 0 to 6. 3. The game ends if: o A player connects four in a row, either horizontally, vertically, or diagonally. o The board is full, resulting in a draw. You can expand on this game by adding additional features like AI for a single-player mode or visual improvements using libraries like pygame. Connect Four Game Pseudocode ************************ Initialize constants: ROWS = 6 COLS = 7 Initialize a 6x7 game board with empty cells (0s) Define function print_board(board): Print the board to the console (flipped vertically) Define function is_valid_location(board, col): Return True if the top cell in the selected column is empty (0), otherwise False Define function get_next_open_row(board, col): For each row from top to bottom: If the cell in that row and column is empty (0): Return the row index Define function drop_piece(board, row, col, piece): Place the piece in the specified row and column of the board Define function check_win(board, piece): For each possible starting location in the board: Check for horizontal, vertical, and diagonal four-in-a-row for the given piece If a four-in-a-row is found, return True Return False if no four-in-a-row is found Define function connect_four(): Set game_over = False Set turn = 0 Print the initial board While game_over is False: If turn is even (Player 1's turn): Set piece = 1 Display "Player 1's turn" Else (Player 2's turn): Set piece = 2 Display "Player 2's turn" Prompt the player to choose a column (0 to 6) If chosen column is valid (is_valid_location(board, col)): Find the next open row in the selected column (get_next_open_row) Place the piece in that row and column (drop_piece) If this move results in a win (check_win(board, piece)): Print the board Display "Player {piece} wins!" Set game_over = True Print the current board Increment turn by 1 Else: Display "Column full. Choose another column." If the board is completely filled and no winner is found: Display "The game is a draw!" Set game_over = True Run the connect_four() function to start the game ****************** Click here for the first half of the Python solution. Required files: • PX_lastname_Connect4.py (Python code) • PX_lastname_Connect4.png (Screenshot of output) • PX_lastname_Connect4.mp4 (Video of running program) Submit all files to Google Classroom.