Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use py only Connect Four is a twoplayer board game where players drop a coloured disc into a seven column by six row grid which

use py only

image text in transcribedimage text in transcribed
Connect Four is a twoplayer board game where players drop a coloured disc into a seven column by six row grid which is arranged vertically' During a move, a player drops a single disc into a column, with the disc falling straight down so that it occupies the lowest available space within the column. An image of a Connect Four board can be seen below' Complete the ma ke_move( ) function that handles a single move in Connect Four. This function takes 3 parameters: 1. The string player, representing the player making the move. You can assume that the player will either be "X" or "O". 2. The integer column, representing the column in which the player wants to place their disc' The first column is numbered 0, the second column is numbered 1 and so on. 3. The list of strings board, representing the Connect Four board. The list has a length of 6. Each element of the list is a string of length 7 and represents a row on the board. The string at index 0 of the board is the top row' the string at index 1, the row below that, and so on. In the row string, the characters "0" and "X" represent player discs while the character "*" represents an empty slot. When a player makes an invalid move, i.e. attempts to insert a disc into a column that is full, the function should print a message informing the player that the move is invalid. The board remains unchanged. When a player makes a valid move, the lowest row on the board with a vacant space in the selected column, should have its string updated so that the player character appears in this location. You can assume that only valid values for the 3 parameters will be passed to the function. Some examples of the function being called are shown below. Please note that the d raw_boa I'd ( ) function has been provided for you. You must not change its implementation. For example: For example: Test Result board = ["*******", "*******", "XO*****", "OX*****", "XO*****", "OX*****"] Before: print ("Before:") draw_board (board) print ( ) 0 * KOX make_move ("X", 1, board) XOXO print ("After:") draw_board (board) After: * X X 0 * X O X * board = ["*0X****", "*X0****", "*0X****", "*X0****", "*0X****", "*X0****"]|Before: print ("Before:") * O X draw_board (board) XO print ( ) X make_move ("X", 1, board) XO print ("After:") X draw_board (board) Y print ( ) Invalid move X, column 1 is full! After: *O X O X X X board = ["* ******", "*******", "XO*#***", "OX*****", "XO*****", "OX*****"] Before: print ("Before:") draw_board (board) print ( ) X make_move ("X", 2, board) 0 make_move ("0", 3, board) X O make_move ("X", 2, board) V print ("After:") draw_board (board) After: 0 X X V

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

What is operatiing system?

Answered: 1 week ago