• API
• FAQ
• Tools
• Archive
daily pastebin goal
22%
SHARE
TWEET

# Untitled

a guest Feb 17th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. def checkmoves():
2.     ok = True
3.     total = []
4.     while len(total)!=8:
5.
6.         ui = input("Player 1 move : ")
7.         if ui not in total:
8.             total.append(ui)
9.             move = ui.split(",")
10.             row = int(move[0]) - 1
11.             col = int(move[1]) - 1
12.             game[row][col] = "X"
13.             for i in range(0, 3):
14.                 print("                      ",game[i])
15.             if(win1()==True):
16.                 pass
17.             else:
18.                 win1()
19.         else:
21.             continue
22.
23.
24.         ui = input("Player 2 move : ")
25.         if ui not in total:
26.             total.append(ui)
27.             move = ui.split(",")
28.             row = int(move[0]) - 1
29.             col = int(move[1]) - 1
30.             game[row][col] = "Y"
31.             for i in range(0, 3):
32.                 print("                      ",game[i])
33.             if (win1() == True):
34.                 pass
35.             else:
36.                 win1()
37.         else:
39.             continue
40.
41.
42. def win1():
43.
44.     if ((game[0]==["X", "X", "X"])|(game[1]==["X", "X", "X"])|(game[2]==["X", "X", "X"])):
45.         print("PLAYER 1 WINS")
46.     elif((game[0][0]=="X")&(game[1][0]=="X")&(game[2][0]=="X")):
47.         print("PLAYER 1 WINS")
48.     elif((game[0][1] == "X") & (game[1][1] == "X") & (game[2][1] == "X")):
49.         print("PLAYER 1 WINS")
50.     elif((game[0][2] == "X") & (game[1][2] == "X") & (game[2][2] == "X")):
51.         print("PLAYER 1 WINS")
52.     elif ((game[0]==["Y", "Y", "Y"])|(game[1]==["Y", "Y", "Y"])|(game[2]==["Y", "Y", "Y"])):
53.         print("PLAYER 2 WINS")
54.     elif((game[0][0]=="Y")&(game[1][0]=="Y")&(game[2][0]=="Y")):
55.         print("PLAYER 2 WINS")
56.     elif((game[0][1] == "Y") & (game[1][1] == "Y") & (game[2][1] == "Y")):
57.         print("PLAYER 2 WINS")
58.     elif((game[0][2] == "Y") & (game[1][2] == "Y") & (game[2][2] == "Y")):
59.         print("PLAYER 2 WINS")
60.     elif ((game[0][0] == "Y") & (game[1][1] == "Y") & (game[2][2] == "Y")):
61.         print("PLAYER 2 WINS")
62.     elif ((game[0][2] == "Y") & (game[1][1] == "Y") & (game[2][0] == "Y")):
63.         print("PLAYER 2 WINS")
64.     elif ((game[0][0] == "X") & (game[1][1] == "X") & (game[2][2] == "X")):
65.         print("PLAYER 1 WINS")
66.     elif ((game[0][2] == "X") & (game[1][1] == "X") & (game[2][0] == "X")):
67.         print("PLAYER 1 WINS")
68.     else:
69.         return True
70.
71.
72. game = [[0, 0, 0],
73.         [0, 0, 0],
74.         [0, 0, 0]]
75.
76. print("--------------------TIC TAC TOE---------------------")
77. print("                     LETS PLAY")
78. for i in range(0,3):
79.     print(game[i])
80. checkmoves()
81. if (win1()==True):
82.     print("NOBODY WINS")
83. else:
84.     win1()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top