Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*PYTHON* this needs to be solved in PYTHON!! please make sure to read the full instructions clearly and use the defined methods as instructions guide.

*PYTHON*
this needs to be solved in PYTHON!! please make sure to read the full instructions clearly and use the defined methods as instructions guide. please and thank you! image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
This lab is designed to introduce students to 2-D lists by recreating one of everyone's favorite childhood games: Connect-Four. You will loop through lists and manipulate them. Your end product should be robust enough to not have a single out-of-bounds exception. Specification You will first start by asking the user for what they wish the height and length of the board to be: What would you like the height of the board to be? 4 What would you like the length of the board to be? 5 Then you will print the empty board: And tell the players what their tokens are: Player 1: x Player 2: 0 The players will take turns placing their tokens by choosing columns. Player 1: Which colunn would you like to choose? 0 Player 2: Which column would you like to choose? 3 until one of them wins! Player 1: Which column would you like to choose? o x0 000 Player 1 won the game! Or until there is a tie! P7ayer 2: Which column would you like to choose? 2 0xxxx000000xxx0o0xxx Draw. Nobody wins. Elements in the 2D-list should be accessible via row-major indexing (board[row][column]). In addition, you should follow the structure by storing the chips (e.9., inserting x in column 0 and then inserting ' 0 ' in column 2) in a 20 list starting from row 0 : Row0x0=Row21 When printing the board, you should print the board upside down (by printing from the last row which is row 3 in our example). So that your output on the console after calling print board(board) would be: Assumptions Students can assume that: - the user will choose for the board dimensions to be 44 or greater. - the user will input a valid column number (from 0 to length-1). - the column that the user chooses to place their token into has space (it is not filled already by other tokens). - players can only win vertically or horizontally, but not diagonally. Required Methods def print_board(board) This will take in the 2D character list for the board and print the board def initialize_board(num_rows, num_cols) This will take in the num_row and num_cols from user input and this will set each spot in the list to " A 2D character list with each spot set to be " " will be retumed. def insert_chip(board, col, chip_type) This will take in the 2D character list for the board. This function piaces the token ( x ' or ' 0 ' denoted as 'chip type') in the column that the user has chosen. Wiil find the next available spot in that column if there are already tokens there. The row that the token is placed in is returned. def check_if_winner(board, col, row, chip_type) This will take in the 2D character list for the board. After a token is added, checks whether the token in this location, of the specified chip type, creates four in a row. Will return True if someone won, and False otherwise. Hint Implement the methods in this order Submissions NOTE: Your output must match the example output "exactly". If it does not, you will not receive full credit for your submission! File: connect_four.py Method: Submit on ZyLabs Sample Output What would you like the height of the board to be? 4 What would you like the length of the board to be? 5 Player 1: x Player 2: 0 Player 1: Which colunn would you 11 ke to choose? 0 Player 2: Which colunn would you like to chooge? 3 3 Player 1: Which column would you like to chooae? 0 Player 2: Which column would you like to choose? 1 Playez 1: Which column would you 11ke to chooge? 0 Player 2: Which columin would you lize to choose? 4 xxx Playez 1: Which column would you 11k to chooze? 2 x= xx=0 Player 2: Which column would you like to chooge? 2 xxxx xoxx x0 xx0 Player 1: Which column would you 11ke to choose? 0 x0= xx,0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

=+ Are they breakable for any reason?

Answered: 1 week ago

Question

=+When and under what circumstances are contracts renegotiated?

Answered: 1 week ago