Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python: A program to implement the tic-tac-toe (Links to an external site.) game. The user is prompted with three options. A player need to

In Python:

A program to implement the tic-tac-toe (Links to an external site.) game.

The user is prompted with three options.

A player need to be able to change the characters used for the game in Settings and save to a file. So that next time the program loads, the settings are loaded from the file. By default you can use Player 1 as 'X' and Player 2 as 'O'. The loading from and saving to file is optional and not graded.

-------------------------------------------------- Welcome To Tic-Tac-Toe Game -------------------------------------------------- Player 1 plays R Player 2 plays U Enter an option: 1. Change player characters 2. Play game 3. Quit 

Choose 1 to update player characters as shown below (and optional save to a config file). These options must be prompted to user until Quit is selected.

1 Enter Player1 character:X Enter Player2 character:O Enter Y or y to save these settings for later:y Saved to config. -------------------------------------------------- Welcome To Tic-Tac-Toe Game -------------------------------------------------- Player 1 plays X Player 2 plays O Enter an option: 1. Change player characters 2. Play game 3. Quit 

When user enter option to play a game, display the tic-tac-toe board. You may decide how you want to represent the board. One example is shown below. Another is shown in Practice Problems: Loops Q14. You need to display the valid moves a player can enter as shown below depending on the board you display to the user.

2 | 1 | 2 | 3 -------------- a| | | -------------- b| | | -------------- c| | | Player 1 plays X Player 2 plays O Player 1, please enter any empty cell location (a1, a2, a3, b1, b2, b3, c1, c2, c3) 

Make sure you understand the rules if the game. Some end game configurations are shown below.

* Player with same characters in diagonal win

Player 1 plays X Player 2 plays O Player 1, please enter any empty cell location (a2, b3, c1, c2, c3)c3 | 1 | 2 | 3 -------------- a| X | | O -------------- b| O | X | -------------- c| | | X Player 1 wins! 

* Player that gets matching row wins

Player 1 plays X Player 2 plays O Player 2, please enter any empty cell location (a3, b2, b3, c3)a3 | 1 | 2 | 3 -------------- a| O | O | O -------------- b| X | | -------------- c| X | X | Player 2 wins! 

* Player that gets matching column wins

Player 1 plays X Player 2 plays O Player 1, please enter any empty cell location (a3, b3, c2)c2 | 1 | 2 | 3 -------------- a| O | X | -------------- b| X | X | -------------- c| O | X | O Player 1 wins! 

* The game end in a tie

Player 1 plays X Player 2 plays O Player 1, please enter any empty cell location (c3)c3 | 1 | 2 | 3 -------------- a| X | O | X -------------- b| X | O | O -------------- c| O | X | X Game ends. There are no winners. 

The player may lose, win or tie if neither player win. You need to keep track of the player statistics that need to be displayed when the user chooses 'Quit' option. The statistics need to keep track of the number of wins, loses and ties for each player.

-------------------------------------------------- Welcome To Tic-Tac-Toe Game -------------------------------------------------- Player 1 plays X Player 2 plays O Enter an option: 1. Change player characters 2. Play game 3. Quit 3 Player Statistics -------------------------------------------------- Player Name Wins Losses Ties -------------------------------------------------- Player 1 2 0 1 Player 2 0 2 1 

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