
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Can you complete this code so the connect 4 game works
![def main ():
widthSet = False
heightSet = False
while not widthSet:
try:
again.")
again.")
again.")
width = int(input("Enter the width of your game board (4-10):" ) )
if width >= 4 and width <= 10:
widthSet = True
else:
except:
while not heightSet:
try:
print("The width must be an integer from 4-10. Please try
print("The width must be an integer from 4-10. Please try again.")
height = int(input("Enter the height of your game board (4-10): "))
if height >= 4 and height <= 10:
heightSet = True
print("The height must be an integer from 4-10. Please try
except:
else:
print("The height must be an integer from 4-10. Please try
board Board (width, height)
allPlayersAdded = False
players = []
while not allPlayersAdded:
validName = False
while not validName:
name = input("Enter this player's name:")
validName = True
for player in players:
if player.getName() name:
Please try again.")
if name
main ()
validName = False
print("There is already a player called " + name +
if name == "Nobody":
validName = False
print("You cannot use the name \"Nobody\". Please try again.")
newPlayer = Player(name, len(players) + 1)
players.append(newPlayer)
print("Player " + str(newPlayer.getNumber()) + is:
if len (players) > 1 and len (players) < 4:
addMore = input("Keep adding players (y/n)")
elif len(players) == 4:
==
if addMore.lower() != "y" and addMore.lower() != "yes":
allPlayersAdded = True
allPlayersAdded = True
print ()
print("This game has " + str(len (players)) + players:")
for player in players:
print (player.getName())
game Over = False
winner = "Nobody"
while not gameOver:
for player in players:
print ()
print(player.getName() + "
board.display ( )
player.makeMove (board)
winner = player.checkWinner (board)
board.display()
input (winner + " wins the game!")
main ':
11
I it's your turn:")
if winner != "Nobody" or board.boardFull ():
game Over = True
break
+ name)](https://content.bartleby.com/qna-images/question/cd7db657-241e-4a8b-968f-cbf232efbcce/149bdb15-e811-45f3-bd47-2c37cb18eb6c/67s1vk3_thumbnail.jpeg)
Transcribed Image Text:def main ():
widthSet = False
heightSet = False
while not widthSet:
try:
again.")
again.")
again.")
width = int(input("Enter the width of your game board (4-10):" ) )
if width >= 4 and width <= 10:
widthSet = True
else:
except:
while not heightSet:
try:
print("The width must be an integer from 4-10. Please try
print("The width must be an integer from 4-10. Please try again.")
height = int(input("Enter the height of your game board (4-10): "))
if height >= 4 and height <= 10:
heightSet = True
print("The height must be an integer from 4-10. Please try
except:
else:
print("The height must be an integer from 4-10. Please try
board Board (width, height)
allPlayersAdded = False
players = []
while not allPlayersAdded:
validName = False
while not validName:
name = input("Enter this player's name:")
validName = True
for player in players:
if player.getName() name:
Please try again.")
if name
main ()
validName = False
print("There is already a player called " + name +
if name == "Nobody":
validName = False
print("You cannot use the name \"Nobody\". Please try again.")
newPlayer = Player(name, len(players) + 1)
players.append(newPlayer)
print("Player " + str(newPlayer.getNumber()) + is:
if len (players) > 1 and len (players) < 4:
addMore = input("Keep adding players (y/n)")
elif len(players) == 4:
==
if addMore.lower() != "y" and addMore.lower() != "yes":
allPlayersAdded = True
allPlayersAdded = True
print ()
print("This game has " + str(len (players)) + players:")
for player in players:
print (player.getName())
game Over = False
winner = "Nobody"
while not gameOver:
for player in players:
print ()
print(player.getName() + "
board.display ( )
player.makeMove (board)
winner = player.checkWinner (board)
board.display()
input (winner + " wins the game!")
main ':
11
I it's your turn:")
if winner != "Nobody" or board.boardFull ():
game Over = True
break
+ name)
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 10 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Please help. How do I create the pack man game belowarrow_forwardMinecraft is an open-world video game based on placing and interacting with 3D textured blocks. If you are not familiar with the game, each player has a personal inventory which can hold a limited number of blocks and items. Specific blocks and items can be combined on a crafting table to form new items. For example, three wheats arranged in a horizontal line on a crafting table gives the player one loaf of bread. These combinations are known as crafting recipes and the game has hundreds of them. This question deals with the recipe for making a cake. One cake requires 1 egg. 2 sugars, 3 wheats and 3 buckets of milk. Your job is to build a program to help the player determine how many cakes they can make based on the number of ingredients that they have. Crafting Figure 2: A screenshot from Minecraft showing a crafting table showing the recipe for making a cake. Your program won't make this picture, this is just showing you the rules for making a cake! Most items in the player's…arrow_forwardYou have some questionable legacy code (that doesn't use interfaces) that you want to enhance, but you don't want to risk breaking other code that uses it. Which pattern would you use? Decorator Null Object O Adapter Proxyarrow_forward
- Where did you get the 0.8 from can you provide more inforamtion please?arrow_forwardwhat is the hardest about the autolayout system?arrow_forwardyou please help me with this code because I am struggling, I added my code in the photo:question that I need help with:you will develop an AI for a game in which two players take turns placing 1 x 2 dominoes on a rectangular grid. One player must always place his dominoes vertically, and the other must always place his dominoes horizontally. The last player who successfully places a domino on the board wins. an infrastructure that is compatible with the provided GUI has been suggested. However, only the search method will be tested, so you are free to choose a different approach if you find it more convenient to do so. The representation used for this puzzle is a two-dimensional list of Boolean values, where True corresponds to a filled square and False corresponds to an empty square.tasks: In the DominoesGame class, write a method is_legal_move(self, row, col, vertical) that returns a Boolean value indicating whether the given move can be played on the current board. A legal move must…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education