Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help ive been stuck on this for 2 days and i dont get it. it has to be in python only python Overview This
please help
ive been stuck on this for 2 days and i dont get it.
it has to be in python
Overview This lab is designed to introdoce stadents to 2-D lists by reercating one of everyone's fivorite chillhood games Connect-Four. You will loop through lists and munipulate them. Your end peodact should be robust enough to not have a single Out-of bounds Fxeeptiont Specification You will first sart by asking the user for what thcy wish the height and length of the boand 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 yoe will priat the enpty board: And will the players what their wiens are: Player 1: x Player 2: o The players will take lums placing their toliens by choosing columns... Player 1: which coluen would you like to choose? Player 2: Which coluen would you like to choose? 3 x0= , uetil one of then wins! Player 1: Which colunn would you like to choose? e x x... x0. 000 Player 1 won the gane! Or until there is a tie! player 2: which colunh would you like to choose? 2 Oraw. Nobody wins. Elements in the 2D-list should be accessible vin row-major indexing (beard|ron|lcolumn]]. In additien, ven columin 2) in a 2D list starting from ron e: Row x a x+0+ Row 1 Row 2 Rew 1 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 returned. def insert_chip(board, col, chip_type) This will take in the 2D character list for the board. This function places the token ( x ' or ' o ' denoted as 'chip type') in the column that the user has chosen. Will 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. 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 column would you lake to choose? Player 2: which colunn would you like to choose? 3 Player 1: which colunn would you like to choose? Player 2: Which colunn would you like to choose? I Player 1: which coluan would you like to choose? x x x=0= Player 2: which colunn would you like to choose? 4 x000 Player 1: which colinn would you like to choose? 2 x== x==0 Player 2: Which colunn would you 1ike to chosse? 2 x= x0= 0 Player 1: Which colunn would you like to choose? e x x=0= 000 only python
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started