forked from abhishekdoifode1/Hacktoberfest2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stone_paper_scissors.py
67 lines (65 loc) · 2.46 KB
/
Stone_paper_scissors.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
#Program for an interactive game of "rock paper scissors", player can play as many times as the player wants
from random import randint
things=["rock","paper","scissors"] #For the choices of AI
thingsP={"R":"rock","P":"paper","S":"scissors"} #For the choices of player , so that player,s choice can be displayed , makes game more interactive
a="Y"
P=0
C=0
while(a=="Y" or a=="y"):
ch=input("Enter R for rock , P for paper and S for scissors:")
ch=ch.upper() #So that the game is not case-sensitive , will kill all the fun!
pch=thingsP[ch]
chAI=things[randint(0,2)] #Choice of the AI
print("You chose",pch,"and AI chose",chAI) #Showing the choices of both the player and game
if(chAI):
if(ch=="R"):
if(chAI=="paper"):
P-=1
c=+1
print("Oh no!!!You lost to AI!")
print("AI's score:",C)
elif(chAI=="scissors"):
P+=1
c=-1
print("Yes!!!You beat the AI!")
print("Your score:",P)
print("AI's score:",C)
else:
print("Nothing happens")
print("Your score:",P)
print("AI's score:",C)
elif(ch=="P"):
if(chAI=="scissors"):
P-=1
c=+1
print("Oh no!!!You lost to AI!")
print("Your score:",P)
print("AI's score:",C)
elif(chAI=="rock"):
P+=1
c=-1
print("Yes!!!You beat the AI!")
print("Your score:",P)
print("AI's score:",C)
else:
print("Nothing happens")
print("Your score:",P)
print("AI's score:",C)
elif(ch=="S"):
if(chAI=="rock"):
P-=1
c=+1
print("Oh no!!!You lost to AI!")
print("Your score:",P)
print("AI's score:",C)
elif(chAI=="paper"):
P+=1
c=-1
print("Yes!!!You beat the AI!")
print("Your score:",P)
print("AI's score:",C)
else:
print("Nothing happens")
print("Your score:",P)
print("AI's score:",C)
a=input("Play Again? Press n/N for no...else press Y/y to continue:") #Provides the choice for the player to play again as many times as they want