Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def checkmoves():
- ok = True
- total = []
- while len(total)!=8:
- ui = input("Player 1 move : ")
- if ui not in total:
- total.append(ui)
- move = ui.split(",")
- row = int(move[0]) - 1
- col = int(move[1]) - 1
- game[row][col] = "X"
- for i in range(0, 3):
- print(" ",game[i])
- if(win1()==True):
- pass
- else:
- win1()
- else:
- print("ALREADY OCCUPIED")
- continue
- ui = input("Player 2 move : ")
- if ui not in total:
- total.append(ui)
- move = ui.split(",")
- row = int(move[0]) - 1
- col = int(move[1]) - 1
- game[row][col] = "Y"
- for i in range(0, 3):
- print(" ",game[i])
- if (win1() == True):
- pass
- else:
- win1()
- else:
- print("ALREADY OCCUPIED")
- continue
- def win1():
- if ((game[0]==["X", "X", "X"])|(game[1]==["X", "X", "X"])|(game[2]==["X", "X", "X"])):
- print("PLAYER 1 WINS")
- elif((game[0][0]=="X")&(game[1][0]=="X")&(game[2][0]=="X")):
- print("PLAYER 1 WINS")
- elif((game[0][1] == "X") & (game[1][1] == "X") & (game[2][1] == "X")):
- print("PLAYER 1 WINS")
- elif((game[0][2] == "X") & (game[1][2] == "X") & (game[2][2] == "X")):
- print("PLAYER 1 WINS")
- elif ((game[0]==["Y", "Y", "Y"])|(game[1]==["Y", "Y", "Y"])|(game[2]==["Y", "Y", "Y"])):
- print("PLAYER 2 WINS")
- elif((game[0][0]=="Y")&(game[1][0]=="Y")&(game[2][0]=="Y")):
- print("PLAYER 2 WINS")
- elif((game[0][1] == "Y") & (game[1][1] == "Y") & (game[2][1] == "Y")):
- print("PLAYER 2 WINS")
- elif((game[0][2] == "Y") & (game[1][2] == "Y") & (game[2][2] == "Y")):
- print("PLAYER 2 WINS")
- elif ((game[0][0] == "Y") & (game[1][1] == "Y") & (game[2][2] == "Y")):
- print("PLAYER 2 WINS")
- elif ((game[0][2] == "Y") & (game[1][1] == "Y") & (game[2][0] == "Y")):
- print("PLAYER 2 WINS")
- elif ((game[0][0] == "X") & (game[1][1] == "X") & (game[2][2] == "X")):
- print("PLAYER 1 WINS")
- elif ((game[0][2] == "X") & (game[1][1] == "X") & (game[2][0] == "X")):
- print("PLAYER 1 WINS")
- else:
- return True
- game = [[0, 0, 0],
- [0, 0, 0],
- [0, 0, 0]]
- print("--------------------TIC TAC TOE---------------------")
- print(" LETS PLAY")
- for i in range(0,3):
- print(game[i])
- checkmoves()
- if (win1()==True):
- print("NOBODY WINS")
- else:
- win1()
Add Comment
Please, Sign In to add comment