Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Connect Four is a game that alternates player 1 and player 2. You should keep track of whose turn it is next. Create a program

Connect Four is a game that alternates player 1 and player 2. You should keep track of whose turn it is next. 


 Create a program that models the structure above. Create functions: 


• Initialization – print “Setting up the game”. Ask each player their name.


• Teardown – print “Destroying the game” 


• Accept Input – accept a letter for which column of the game we are going to drop a disc into. Valid letters are A-G (7 columns). You should designate a letter for “Quit the game”. Input must be returned from this function. 


• Update the state of the world – pass the input data to this function. Since we do not have a “world” right now, choosing “A” is the “winning move”, all other letters make the game continue. This method must not print anything. It only does calculations. Results from here update the “global state.” • Display the state of the world – Print the result calculated in the state of the world. Later, this should print the board. 


• Main – call initialization, then loop until a flag is set (game over or a player quit), calling accept input, update and display. Outside of the loop, call teardown. Make variables to define the size of the board (width and height). These can be global variables. Other global variables might include player names, which player should play next and “did anyone quit yet?”

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres the Python code for the Connect Four game structure as described def initialization printSetti... 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

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students also viewed these Operating System questions

Question

What is the difference between a hazard and danger?

Answered: 1 week ago