-
Notifications
You must be signed in to change notification settings - Fork 0
/
Project1RockPaperScissors.py
87 lines (75 loc) · 3.04 KB
/
Project1RockPaperScissors.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
# Importing the random module for generating random choices
import random
# Dictionary mapping game choices to emojis
dic = {
"Rock": "🗿",
"Paper": "📃",
"Scissors": "✂️",
}
# Initializing variables to keep track of scores
Player_Score = 0
Computer_Score = 0
Total_Tie = 0
# Printing a welcome message for the game
print()
print("SAB KHELENGE🤝 - ROCK🗿, PAPER📃 ,SCISSORS✂️, GAME🕹️")
# Main game loop
while True:
# Asking the player to input their move
Player_Move = input("\nEnter Your choice (Rock, Paper, Scissors?) :- ")
# Validating player's input
while Player_Move != "Rock" and Player_Move != "Paper" and Player_Move != "Scissors":
print("\nPlease🙏 Select Correct Choice!!🗿📃✂️")
Player_Move = input("\nEnter Your choice (Rock, Paper, Scissors?) :- ")
# List of possible actions and selecting computer's move randomly
possible_actions = ["Rock", "Paper", "Scissors"]
Computer_Move = random.choice(possible_actions)
# Displaying player and computer choices
print("\nYou Choose :- ", dic[Player_Move], "\nComputer Choose :- ", dic[Computer_Move], "\n")
# Checking game outcomes
if Player_Move == Computer_Move:
print("Both players selected", dic[Player_Move], "\n\nIt's a Tie!😅🤝")
Total_Tie += 1
elif Player_Move == "Rock":
if Computer_Move == "Scissors":
print("Rock smashes Scissors!\n" "\nPlayer Win!🥳")
Player_Score += 1
else:
print("Paper covers Rock!\n" "\nComputer Win!🎉")
Computer_Score += 1
elif Player_Move == "Paper":
if Computer_Move == "Rock":
print("Paper covers Rock!\n" "\nPlayer Win!🥳")
Player_Score += 1
else:
print("Scissors Cuts Paper!\n" "\nComputer Win!🎉")
Computer_Score += 1
elif Player_Move == "Scissors":
if Computer_Move == "Paper":
print("Scissors cuts Paper!\n" "\nPlayer Win!🥳")
Player_Score += 1
else:
print("Rock smashes Scissors!\n" "\nComputer Win!🎉")
Computer_Score += 1
# Asking if the player wants to play again
play_again = input("\nDo You Want to Play again? (Yes/No) :- ")
if play_again == "No":
break
# Validating player's response for playing again
Flag = True
while play_again != "Yes":
Flag = True
print("\nPlease🙏 Select Correct Option!!(Yes/No?)")
play_again = input("\nDo You Want to Play again? (Yes/No) :- ")
if play_again == "No":
Flag = False
break
# Breaking out of the loop if player chooses not to play again
if Flag == False:
break
# Printing end game message and final scores
print("\nGame Ends🔚 Here!!, Thank You🙏 For Playing🙂")
print("\nFinal Scores of Both of the Players🙌 :- 👇")
print("\nComputer Score", Computer_Score, "Points✌️.")
print("\nPlayer Score", Player_Score, "Points👏.")
print("\nTotal Numbers of Tie🤝", Total_Tie, "in the Game🎮.")