Skip to content

Commit ff36b3b

Browse files
Add files via upload
Rock paper scissors game #features: 1. single player mode 2. double player mode
1 parent cbf2899 commit ff36b3b

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import random
2+
3+
4+
# Defining the rules for the game
5+
#p = paper , s = stone , x = scissiors
6+
7+
rule1 = "p" > "s"
8+
rule2 = "s" > "x"
9+
rule3 = "x" > "p"
10+
i = 0
11+
12+
#using random no generator for single player mode
13+
no_of_players = input("Press 'a' for single player mode and press 'd' for double player mode")
14+
if no_of_players == "a" :
15+
print("This is single player mode")
16+
for i in range (0,5):
17+
i += 1
18+
roll1 = random.randint(1,3)
19+
if roll1 == 1 :
20+
roll1 = "s"
21+
elif roll1 == 2:
22+
roll1 = "pr"
23+
elif roll1 == 3:
24+
roll1 = "x"
25+
user3 = input("press 's' for stone, press 'p' for paper, press 'x' for scissior")
26+
27+
if user3 == roll1 :
28+
print("Draw")
29+
elif user3 > roll1:
30+
print("You win!")
31+
elif user3 < roll1:
32+
print("You lose!")
33+
34+
print("Thanks for playing")
35+
# else:
36+
elif no_of_players == "d":
37+
for i in range (0,5):
38+
i += 1
39+
print("This is double player mode")
40+
user1 = input( "Player1 : press 's' for stone, press 'p' for paper, press 'x' for scissior -")
41+
user2 = input("Player2 : press 's' for stone, press 'p' for paper, press 'x' for scissior -")
42+
43+
if user1 == user2 :
44+
print("Draw")
45+
elif user1 > user2:
46+
print("Player 1 wins this round")
47+
elif user2 > user1:
48+
print("Player 2 wins this round")
49+
print("Thanks for playing")
50+
51+

0 commit comments

Comments
 (0)