Created
October 3, 2022 09:32
-
-
Save DuskyElf/3a85bca74e4ca3a9743944a12a21267d to your computer and use it in GitHub Desktop.
Very Simple Rps game in python
This file contains hidden or 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
| from random import randint | |
| gestures = [ | |
| """ | |
| _______ | |
| ---' ____) | |
| (_____) | |
| (_____) | |
| (____) | |
| ---.__(___) | |
| """, | |
| """ | |
| _______ | |
| ---' ____)____ | |
| ______) | |
| _______) | |
| _______) | |
| ---.__________) | |
| """, | |
| """ | |
| _______ | |
| ---' ____)____ | |
| ______) | |
| __________) | |
| (____) | |
| ---.__(___) | |
| """ | |
| ] | |
| # 0 is rock | |
| # 1 is paper | |
| # 2 is scissors | |
| # None means draw | |
| # True means first player won | |
| # False means first player lost | |
| outcomes = [ | |
| [None, False, True], | |
| [True, None, False], | |
| [False, True, None], | |
| ] | |
| while True: | |
| wanna_play = input("Do you want to play a round? (y/n): ").lower() | |
| if wanna_play not in 'yn': | |
| print(f"Error: Invalid input {wanna_play}, try y/n") | |
| exit() | |
| if wanna_play == 'n': | |
| break | |
| bot_input = randint(0, 2) | |
| user_input = input("Your choice (0/1/2): ") | |
| if user_input not in '012': | |
| print(f"Error: Invalid input {user_input}, try 0/1/2") | |
| exit() | |
| user_input = int(user_input) | |
| print("Bot Played:") | |
| print(gestures[bot_input]) | |
| print("You Played") | |
| print(gestures[user_input]) | |
| did_player_won = outcomes[user_input][bot_input] | |
| if did_player_won is None: | |
| print("It's a draw") | |
| elif did_player_won: | |
| print("You won!") | |
| else: | |
| print("Bot won, try next time!") | |
| print() # For a new line | |
| print("Bye!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment