forked from I-RoshanKumar/Beginner_Hactoberfest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rock_Paper_Scissors_Audio_Game.py
104 lines (102 loc) · 2.82 KB
/
Rock_Paper_Scissors_Audio_Game.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
import random
import pyttsx3
import speech_recognition as sr
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
engine.setProperty('rate', 150)
engine.setProperty('volume', 1.0)
engine.say("Enter your name")
engine.runAndWait()
print("Enter your name:",end = ' ')
name = input()
print()
print()
print("Welcome")
engine.say("Welcome")
engine.runAndWait()
print()
print()
count = 1
userPoint = 0
compPoint = 0
while(count <= 10):
print("Round " + str(count) + " :")
engine.say("Round " + str(count))
engine.runAndWait()
print()
print("Enter your choice:",end=' ')
engine.say("Enter your choice:")
engine.runAndWait()
user = input()
if random.randint(1,3) == 1:
comp = "Rock"
elif random.randint(1,3) == 2:
comp = "Paper"
else:
comp = "Scissors"
print("Computer's choice: " + comp)
engine.say("Computer's choice: " + comp)
engine.runAndWait()
count += 1
if user == "Rock" and comp == "Paper":
print("Paper beats Rock")
engine.say("Paper beats Rock")
engine.runAndWait()
compPoint += 1
elif user == "Paper" and comp == "Rock":
print("Paper beats Rock")
engine.say("Paper beats Rock")
engine.runAndWait()
userPoint += 1
elif user == "Paper" and comp == "Scissors":
print("Scissors beats Paper")
engine.say("Scissors beats Paper")
engine.runAndWait()
compPoint += 1
elif user == "Scissors" and comp == "Paper":
print("Scissors beats Paper")
engine.say("Scissors beats Paper")
engine.runAndWait()
userPoint += 1
elif user == "Scissors" and comp == "Rock":
print("Rock beats Scissors")
engine.say("Rock beats Scissors")
engine.runAndWait()
compPoint += 1
elif user == "Rock" and comp == "Scissors":
print("Rock beats Scissors")
engine.say("Rock beats Scissors")
engine.runAndWait()
userPoint += 1
elif user == comp:
print("Tie")
engine.say("Tie")
engine.runAndWait()
userPoint += 1
compPoint += 1
print()
print(name + "'s points: " + str(userPoint))
engine.say(name + "'s points: " + str(userPoint))
engine.runAndWait()
print("Computer's points: " + str(compPoint))
engine.say("Computer's points: " + str(compPoint))
engine.runAndWait()
print()
print()
print()
print()
print()
print("Result:")
engine.say("Result")
engine.runAndWait()
if userPoint > compPoint:
print(name + " wins")
engine.say("Congratulations" + name + "You won the match")
elif compPoint > userPoint:
print("Computer wins")
engine.say("Sorry" + name + "Better luck next time")
else:
print("Match is drawn")
engine.say("Match is drawn")
engine.runAndWait()