Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This needs to be a python function and please don't look at the other chegg answers with this question because they are not right. Thanks!

This needs to be a python function and please don't look at the other chegg answers with this question because they are not right. Thanks!image text in transcribed

Write a function named game () that accepts one argument, the number of players. The game () function should complete the following tasks: Initialize a List of 9 empty Strings representing the 9 squares in the Tic-Tac-Toe board O HINT: This could be 9 Strings with each containing a single space character Draw the initial (empty) game grid Setup a for loop that repeats 9 times o If it's a human player's turn: . Prompt for a grid location to place their marker (ie: "A1") . If the selected location is outside the game grid (ie: "Al") . Continue to prompt the player until a a valid grid location is entered . If the selected grid location is not empty: . Continue to prompt the player until an empty grid location is entered . Update the corresponding List location with the correct player marker (x or O) o Else if it's the computer player's turn: . Select a random, empty grid location and place the o marker. o Draw the updated grid including the player's marker o call the check() function with the List as an argument to determine if there's a winner o If a player has won the game: . Display winning message and end the game () function Display "game is a tie" message as shown in the example output

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions