Skip to content

Commit 5b974fe

Browse files
authored
Merge pull request #168 from The-APK/main
Improvised Rock Paper Scissors. Pull Req for Hacktoberfest.
2 parents 5650148 + f4e37f2 commit 5b974fe

File tree

2 files changed

+118
-51
lines changed

2 files changed

+118
-51
lines changed

R/rock paper scissors/README.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
1-
# ROCK PAPER SCISSOR GAME
2-
## Description
3-
A simple CLI-based rock, paper, scissors game that allows the user to play against the computer.<br>
4-
Run the game by typing `python3 main.py` in the terminal if on Linux, or `python main.py` if on Windows.
5-
6-
## How to play
7-
Upon running the program, the instructions will be displayed.
8-
The user will be asked to enter their choice. The objects rock, paper, scissors are mapped to the integers 1, 2, 3 respectively. <br>
9-
Making the proper choice leads to the computer selecting it's own choice.
10-
The winner will be decided by comparing the player and the computer's choices based on the generic game rule.
11-
12-
## More information
13-
Author: [Aishik Mukherjee](https://aishik999.github.io)
14-
<br>
15-
Language: Python3
1+
# Rock Paper Scissors Game
2+
3+
This is a simple Command Line Interface Rock Paper Scissors game written in Python language. The game can be played against the computer, where the computer chooses a random move.
4+
5+
6+
## How to Play
7+
8+
To play the game, run the main.py file in your Python environment.
9+
10+
The program will prompt the user to select either rock, paper, or scissor in the CLI.
11+
After the user selects their choice, the computer will randomly choose one of the three options as well. The program will then determine the winner based on the classic rock paper scissors rules:
12+
13+
- Rock beats scissors
14+
- Scissors beats paper
15+
- Paper beats rock
16+
17+
The program will display the user's choice, the computer's choice, and the outcome of the game (win, lose, or tie).
18+
19+
## Requirements
20+
21+
This program was developed using Python 3. To run the program, you will need to have Python 3 installed on your computer.
22+
23+
24+
## Acknowledgements
25+
26+
- This project was inspired by the classic game of rock paper scissors.
27+
- Special thanks to anyone whose code was used as a reference.
28+
1629
<br>
17-
OS: Linux
30+
31+
Created by [Aswin P Kumar](https://github.com/AswinPKumar01)
32+
33+
Previous Contributor: [Aishik Mukherjee](https://aishik999.github.io)

R/rock paper scissors/main.py

Lines changed: 86 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,88 @@
11
import random
22

3-
banner = """
4-
█▀█ █▀█ █▀▀ █▄▀ ░   █▀█ ▄▀█ █▀█ █▀▀ █▀█ ░   █▀ █▀▀ █ █▀ █▀ █▀█ █▀█ █▀
5-
█▀▄ █▄█ █▄▄ █░█ █   █▀▀ █▀█ █▀▀ ██▄ █▀▄ █   ▄█ █▄▄ █ ▄█ ▄█ █▄█ █▀▄ ▄█
6-
"""
7-
8-
def game():
9-
while True:
10-
print("\n1. Rock 🪨\n2. Paper 📜\n3. Scissors ✂️")
11-
user_choice = int(input("Enter your choice: "))
12-
if user_choice not in [1, 2, 3]:
13-
print("Invalid choice. Please enter 1, 2, or 3.")
14-
continue
15-
16-
choices = {1: 'Rock', 2: 'Paper', 3: 'Scissors'}
17-
computer_choice = random.randint(1, 3)
18-
19-
print("Computer chose: ", choices[computer_choice])
20-
21-
if user_choice == computer_choice:
22-
print("It's a draw!")
23-
elif (user_choice == 1 and computer_choice == 3) or (user_choice == 2 and computer_choice == 1) or (user_choice == 3 and computer_choice == 2):
24-
print("Congratulations! You win! 🎉")
25-
else:
26-
print("Computer wins! Better luck next time! 🥹")
27-
28-
play_again = input("Do you want to play again? (y/n): ")
29-
if play_again.lower() != "y":
30-
print("Thanks for playing! 👋")
31-
exit()
32-
else:
33-
game()
34-
35-
if __name__ == "__main__":
36-
print(banner)
37-
game()
3+
print("WELCOME TO THE GAME OF STONE, PAPER, SCISSORS!!")
4+
5+
round = int(input("How many rounds you would like to play? "))
6+
user_point = 0
7+
comp_point = 0
8+
9+
rock = '''
10+
_______
11+
---' ____)
12+
(_____)
13+
(_____)
14+
(____)
15+
---.__(___)
16+
'''
17+
18+
paper = '''
19+
_______
20+
---' ____)____
21+
______)
22+
_______)
23+
_______)
24+
---.__________)
25+
'''
26+
27+
scissors = '''
28+
_______
29+
---' ____)____
30+
______)
31+
__________)
32+
(____)
33+
---.__(___)
34+
'''
35+
36+
images = [rock,paper,scissors]
37+
38+
for i in range(round):
39+
40+
print("ROUND: ", i+1)
41+
42+
user_choice = int(input("""What is your play?
43+
Type 0 for Rock
44+
Type 1 for Paper
45+
Type 2 for Scissors\n"""))
46+
47+
if user_choice >= 3 or user_choice < 0:
48+
print("You should either choose Rock, Paper or Scissor")
49+
else:
50+
print(images[user_choice])
51+
52+
computer_choice = random.randint(0, 2)
53+
print("Computer chose:")
54+
print(images[computer_choice])
55+
56+
if user_choice == 0 and computer_choice == 2:
57+
print("Yes! You WON")
58+
user_point+=1
59+
60+
elif computer_choice == 0 and user_choice == 2:
61+
print("Oh No! You LOSE")
62+
comp_point+=1
63+
64+
elif computer_choice > user_choice:
65+
print("Oh No! You LOSE")
66+
comp_point+=1
67+
68+
elif user_choice > computer_choice:
69+
print("Yes! You WON")
70+
user_point+=1
71+
72+
elif computer_choice == user_choice:
73+
print("Toit! It's a DRAW")
74+
print("-----------------------------------------------")
75+
print()
76+
77+
if user_point > comp_point:
78+
print("CONGRATULATIONS!! YOU WON THE GAME ")
79+
80+
elif comp_point > user_point:
81+
print("SORRY, YOU LOST THE GAME")
82+
83+
elif user_point == comp_point:
84+
print("GOOD GAME! ITS A DRAW")
85+
86+
87+
88+

0 commit comments

Comments
 (0)