forked from DevLord9/Newpythonrepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchopsticksgame.py
105 lines (84 loc) · 2.98 KB
/
chopsticksgame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import random
print(
"Welcome to Chopsticks! You will be against a computer. The rules will be in the code. Good Luck!!!!!"
)
list = ["l", "r"]
personhands = [1, 1]
#------------------#
computerhands = [1, 1]
print("Game is starting now!")
while True:
print()
if (personhands[0] == 0):
userInput1 = "r"
elif (personhands[1] == 0):
userInput = "l"
else:
userInput1 = input("Which hand would you like to use? ").lower()
userInput2 = input("Which hand would you like to use on your opposites's hand? ").lower()
if (userInput2 == "l" and computerhands[0] == 0):
userInput2 = "r"
elif (userInput2 == "r" and computerhands[1] == 0):
userInput2 = "l"
if userInput1 == "l" and userInput2 == "l":
computerhands[0] += personhands[0]
elif userInput1 == "l" and userInput2 == "r":
computerhands[1] += personhands[0]
elif userInput1 == "r" and userInput2 == "r":
computerhands[1] += personhands[1]
elif userInput1 == "r" and userInput2 == "l":
computerhands[0] += personhands[1]
comInput1 = list[random.randint(0, 1)]
comInput2 = list[random.randint(0, 1)]
if (personhands[0] + computerhands[0] == 5):
comInput1 = "l"
comInput2 = "l"
if (personhands[1] + computerhands[0] == 5):
comInput1 = "l"
comInput2 = "r"
if (personhands[0] + computerhands[1] == 5):
comInput1 = "r"
comInput2 = "l"
if (personhands[1] + computerhands[1] == 5):
comInput1 = "r"
comInput2 = "r"
if (comInput2 == "l" and personhands[0] == 0):
comInput2 = "r"
elif (comInput2 == "r" and personhands[1] == 0):
comInput2 = "l"
if comInput1 == "l" and comInput2 == "l":
personhands[0] += computerhands[0]
print("\nThe computer pick their left and your left\n")
elif comInput1 == "l" and comInput2 == "r":
personhands[1] += computerhands[0]
print("\nThe computer pick their left and your right\n")
elif comInput1 == "r" and comInput2 == "r":
personhands[1] += computerhands[1]
print("\nThe computer pick their right and your right\n")
elif comInput1 == "r" and comInput2 == "l":
personhands[0] += computerhands[1]
print("\nThe computer pick their right and your left\n")
if (personhands[0] >= 5):
personhands[0] %= 5
if (personhands[1] >= 5):
personhands[1] %= 5
if (computerhands[0] >= 5):
computerhands[0] %= 5
if (computerhands[1] >= 5):
computerhands[1] %= 5
print("You have (", personhands[0], ", ", personhands[1]," )")
print("Computer has (", computerhands[0], ", ", computerhands[1]," )")
if (personhands[0] == 0 and personhands[1] == 0):
personhands[0] = 1
personhands[1] = 1
#------------------#
computerhands[0] = 1
computerhands[1] = 1
temp = input("You lost! Press enter to continue..")
elif (computerhands[0] == 0 and computerhands[1] == 0):
personhands[0] = 1
personhands[1] = 1
#------------------#
computerhands[0] = 1
computerhands[1] = 1
temp = input("Congratulations, you won! Press enter to continue..")