Question: Python Overview This lab is designed to introduce students to 2 - D lists by recreating one of everyone's favorite childhood games: Connect - Four.
Python
Overview
This lab is designed to introduce students to D lists by recreating one of everyone's favorite childhood games: ConnectFour. You will loop through lists and manipulate them. Your end product should be robust enough to not have a single outofbounds exception.
B 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
what would you like the length of the board to be
Then you will print the empty board:
And tell the players what their tokens are:
Player : Player :
The players will take turns placing their tokens by choosing columns...
Player : which column would you like to choose? xPlayer : which column would you like to choose? barx bar baruntil one of them wins!Player : which column would you like to choose? xxoxooOr until there is a tielPlayer : which column would you like to choose? :xxxxxxx::xxxx:Draw Nobody wins.Elements in the list should be accessible via rowmajor indexing boardrowcolumn In addition, you should follow the structure by storing the chips eg inserting x in column and then inserting O in column in a list starting from row
When printing the board, you should print the board upside down by printing from the last row which is row in our example So that your output on the console after calling printboardboard would be:
Assumptions
Students can assume that:
the user will choose for the board dimensions to be or greater.
the user will input a valid column number from to length
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 printboardboard
This will take in the character list for the board and print the board.
def initializeboardnumrows, numcols
This will take in the numrow and numcols from user input and this will set each spot in the list to
A character list with each spot set to be will be returned.
def insertchipboard col, chiptype
This will take in the D character list for the board. This function places the token or o denoted as 'chiptype' 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 checkifwinnerboard col, row, chiptype
This will take in the D 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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
