Question: Task 0 We have given you the main function of the game a function named connect _ four. It takes two Player objects, and it
Task
We have given you the main function of the game a function named connectfour. It takes two Player objects, and it will be used to run a game of Connect Four between those two Players. Begin by reading over this function. You will see that it takes some preliminary steps, and that it then enters a loop that repeatedly processes one move by each player. However, the function needed to process a move still needs to be written. That is your next task!
Task
Write a function processmovep b that takes two parameters: a Player object p for the player whose move is being processed, and a Board object b for the board on which the game is being played.
The function will perform all of the steps involved in processing a single move by player p on board b These steps are enumerated below. Note that the function should not be very long, because it should take advantage of the methods in the Player object and Board object that it has been given. Those methods will do almost all of the work for you!
Here are the steps that the function should perform:
Print a message that specifies whose turn it is:
Player Xs turn
or
Player Os turn
Important: You should not need an if statement here. Simply take advantage of the repr method in player to obtain its string representation.
Obtain player ps next move by using p to call the appropriate Player method. Store the move ie the selected column number in an appropriately named variable.
Apply the move to the board by using b to call the appropriate Board method.
Print a blank line, and then print board b
Check to see if the move resulted in a win or a tie by using the appropriate methods in b
If it is a win, print a message that looks like this:
Player X wins in moves. Congratulations!
and return True.
If it is a tie, print It's a tie! and return True.
If it is neither a win nor a tie, the method should simply return False.
Make sure that the method returns the appropriate value either True or False.
Testing processmove
You can test processmove on its own from the console. For example:
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
