Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone please add music to my tic tac toe game? Must be able to copy and paste into python and it run perfect. p1=0;

Can someone please add music to my tic tac toe game?

Must be able to copy and paste into python and it run perfect.

p1=0; p2=0; ct=0; while(True): print("Let's play game tic tac toe "); choices = [] for x in range (0, 9) : choices.append(str(x + 1)) playerOneTurn = True winner = False def printBoard() : print( ' -----') print( '|' + choices[0] + '|' + choices[1] + '|' + choices[2] + '|') print( ' -----') print( '|' + choices[3] + '|' + choices[4] + '|' + choices[5] + '|') print( ' -----') print( '|' + choices[6] + '|' + choices[7] + '|' + choices[8] + '|') print( ' ----- ') while not winner : printBoard() if playerOneTurn : print( "Player 1:") else : print( "Player 2:") try: choice = int(input(">> ")) except: print("please enter a valid field") continue if choices[choice - 1] == 'X' or choices [choice-1] == 'O': print("illegal move, plase try again") continue if playerOneTurn : choices[choice - 1] = 'X' else : choices[choice - 1] = 'O' playerOneTurn = not playerOneTurn for x in range (0, 3) : y = x * 3 if (choices[y] == choices[(y + 1)] and choices[y] == choices[(y + 2)]) : winner = True printBoard() if (choices[x] == choices[(x + 3)] and choices[x] == choices[(x + 6)]) : winner = True printBoard() if((choices[0] == choices[4] and choices[0] == choices[8]) or (choices[2] == choices[4] and choices[4] == choices[6])) : winner = True printBoard() print ("Player " + str(int(playerOneTurn + 1)) + " wins! ") if(playerOneTurn + 1==1): p1=p1+1; else: p2=p2+1; ct=ct+1; if(ct==3): if(p1>p2): print("Player1 wins series"); else: print("Player2 wins series"); break;

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_2

Step: 3

blur-text-image_3

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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions