Skip to content

Commit

Permalink
Merge pull request #51 from Sauvic016/master
Browse files Browse the repository at this point in the history
Basic Game of Rock-Paper-Scissors
  • Loading branch information
fineanmol authored Oct 6, 2020
2 parents c19e6b9 + f4e2a41 commit 7554000
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
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 :(")

0 comments on commit 7554000

Please sign in to comment.