Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Game of Rock-Paper-Scissors #51

Merged
merged 2 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ <h1 class="animated rubberBand delay-4s">Contributors</h1>
<a class="box-item" href="https://github.com/milos5593"><span>Milos Vujinic</span></a>
<a class="box-item" href="https://github.com/senshiii"><span>Sayan Das</span></a>
<a class="box-item" href="https://github.com/Shagufta08"><span>Shagufta Iqbal</span></a>
<a class="box-item" href="https://github.com/ishgary"><span>Ishant Garg</span></a>
<a class="box-item" href="https://github.com/ishgary"><span>Ishant Garg</span></a>
<a class="box-item" href="https://github.com/<Sauvic016>"><span>Sauvic P Choudhury </span></a>
<!--
Add here
format : <a class="box-item" href="https://github.com/<your-username>"><span>Your Name</span></a>
Expand Down
57 changes: 57 additions & 0 deletions game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Simple Game of Rock, Paper, Scissors...

from random import randint
player_wins = 0
AI_wins = 0

print("Hello Player!")
win_score = int(input("Enter the winning score (e.g. 3): "))

while player_wins < win_score and AI_wins < win_score:
print(f"Your Score: {player_wins} AI Score: {AI_wins}")

player = input("\n(Choose Rock, Paper or Scissors...or Enter q to exit...): ").lower()
if player == "quit" or player == "q":
break
random_num = randint(0, 2)
if (random_num == 0):
computer = "rock"
elif (random_num == 1):
computer = "paper"
else:
computer = "scissors"

print(f"The AI plays: {computer}")

if player == computer:
print("It's a tie!")
elif player == "rock":
if computer == "paper":
print("AI wins!")
AI_wins += 1
else:
print("YOU win!")
player_wins += 1
elif player == "paper":
if computer == "rock":
print("YOU win!")
player_wins += 1
else:
print("AI wins!")
AI_wins += 1
elif (player == "scissors"):
if (computer == "rock"):
print("AI wins!")
AI_wins += 1
else:
print("You win!")
player_wins += 1
else:
print("Invalid Entry!")

if player_wins > AI_wins:
print("CONGRATS, YOU BEAT THE AI!")
elif player_wins == AI_wins:
print("YOU'VE MADE FRIENDS WITH THE AI!")
else:
print("YOU LOST AGAINST THE AI! Prepare for World Domination :(")