-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from Sauvic016/master
Basic Game of Rock-Paper-Scissors
- Loading branch information
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 :(") |