Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assignment overview For the final homework assignment you will implement a varia

ID: 3827034 • Letter: A

Question


Assignment overview For the final homework assignment you will implement a variant of the game Connect Four on game boards of arbitrary dimensions (The classic game is played on a 6-row. by-7-column board.) Some basic code has been provided to you which depends on seven functions, six of which you will write for this assignment. The first thing to do is to download homework4.py from Piazza Resources and fill in your information at the top of the file. Inside the file you will find the Board class, which represents the game board, and also a function display-board that has been written for you. Let's explore the Board class a little: class Board: de f init (self num rows, num cols) self num rows num rows self. num cols num cols self slots for i in range (0, num rows) self slots .append for j in range (0, num cols) self. slots (-1) append The game board itself is represented using a list of lists of characters. Each position in the board is called a "slot" and holds either a period, capital letter X, or capital letter O: a represents an empty slot in the board an 'X' represents a piece for player 1. and an o' represents a piece for player 2. The board has at least 4 rows and 4 columns. The piece in -slots to] [01 is in the lower-left comer of the board, whereas the piece in slots [-num-rows-11 [-num-cols-11 is in the upper-right corner of the board:

Explanation / Answer

# PART VI
# Drops a bomb into a given column.
# If the column number is outside the range 1 through num_cols, return -1 and do not change the state of the board.
# Otherwise, remove all the pieces from the column, replacing them with '.', and then return col_num.
# Note that col_num is given as a value in the range 1 through board._num_cols, NOT 0 through board._num_cols-1.
def drop_bomb(board, col_num):
if col_num < 1 or col_num > board._num_cols:
return -1
for i in range(0, board._num_rows):
board._slots[i][col_num-1] = '.'
  
return col_num

# Pastebin code link: https://pastebin.com/2KUuPP9z

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote