From 4020a2f8255c7a9dd14e12e1a3e900bf6c2df48c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 May 2025 00:55:29 +0000 Subject: [PATCH 1/3] Initial plan for issue From d89c0b74fe7a23e46c6f4b9f38d5e09d95e5f864 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 May 2025 00:57:25 +0000 Subject: [PATCH 2/3] Implement Rock-Paper-Scissors game Co-authored-by: raffertyuy <1037626+raffertyuy@users.noreply.github.com> --- .../rock_paper_scissors.cpython-312.pyc | Bin 0 -> 3535 bytes personas/app-dev/games/rock_paper_scissors.py | 102 ++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 personas/app-dev/games/__pycache__/rock_paper_scissors.cpython-312.pyc create mode 100755 personas/app-dev/games/rock_paper_scissors.py diff --git a/personas/app-dev/games/__pycache__/rock_paper_scissors.cpython-312.pyc b/personas/app-dev/games/__pycache__/rock_paper_scissors.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0ce613728d7d4c36e4e8021ae4a1c2d7750c8e8d GIT binary patch literal 3535 zcma)9OKcm*8J;DV@0X|t6FuyVY^xGek!&QOu2tKG>)48{N;1Sm^&<(f;;tpiX3s{B&aThS)>61pA_hl-jq{(D2f8TtR7C-g$@R)i*JmaL*Y~Z8FHz$Afp*z zhr9DX=AZ9>4gVDi`4Nm;-ES>!1`zrW{jdh#e0jbEFAtH3?jVs99eM5!CpteucN`)Q zvr}}z%!_WAU6Nb$+#f=S_#zS;b|ggf#^h^FkS)q)u26a*%+FtQ|i?pSO1B&?l2|m;QG@hA}QRfGVjH8B}q0QORW`JVd}v!?;NOG>jF3)uylF zNhUQXvT0V*N<>!2*auxz zH8O^&lYXovO!7;o$x~ZR7qiv$T88S$Yclwq1`GNBry9fhz=YhewE;mA-^@#bD#5v^ zn#PHM%`uGQF4M)1ZMq;HC1Se3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;>zwNv%Z= zfG<#;tX?w0@jdUGAZE1TFWxZlTSjGZ8-Li1{%XzrG!R{%+X?j6g0X7< z$1`g;_MyGE4?YPF)j}QX`cA077VN1C+rc;1rWq;mB$$LNzpjxTk7M>#;<3M*}F#g{U_cJz)GX-!q%HxeUH=s zJZ-#l%eW;N;rS=tEGvknH09 z>Q0X1zUN&W|2&Mi@F5@J=D5Q%9_|;1?XPh?ha+b=k*mMMAwIaK?>M{b4yP;mZ*TO| tK;4D-p8rBe2%b7b99;|<;o)z+2~g=uzEFdp{V$#~=uv3I`8RIF`9ID(qSXKZ literal 0 HcmV?d00001 diff --git a/personas/app-dev/games/rock_paper_scissors.py b/personas/app-dev/games/rock_paper_scissors.py new file mode 100755 index 0000000..cf4b8a9 --- /dev/null +++ b/personas/app-dev/games/rock_paper_scissors.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 +""" +Rock-Paper-Scissors Game + +A simple console application that allows you to play Rock-Paper-Scissors against the computer. +The game is played best out of 3, meaning the first to reach 3 points wins. +""" + +import random + +def get_user_choice(): + """ + Get the user's choice (rock, paper, or scissors). + Validates input to ensure it's one of the valid options. + + Returns: + str: The user's choice (rock, paper, or scissors) + """ + valid_choices = ["rock", "paper", "scissors"] + + while True: + user_choice = input("Enter your choice (rock, paper, or scissors): ").lower().strip() + if user_choice in valid_choices: + return user_choice + else: + print(f"Invalid choice. Please enter one of: {', '.join(valid_choices)}") + +def get_computer_choice(): + """ + Generate a random choice for the computer. + + Returns: + str: The computer's choice (rock, paper, or scissors) + """ + return random.choice(["rock", "paper", "scissors"]) + +def determine_winner(user_choice, computer_choice): + """ + Determine the winner of a round based on the choices. + + Args: + user_choice (str): The user's choice + computer_choice (str): The computer's choice + + Returns: + str: 'user', 'computer', or 'tie' + """ + if user_choice == computer_choice: + return "tie" + + winning_combinations = { + "rock": "scissors", + "paper": "rock", + "scissors": "paper" + } + + if winning_combinations[user_choice] == computer_choice: + return "user" + else: + return "computer" + +def play_game(): + """ + Main game loop that plays Rock-Paper-Scissors until someone reaches 3 points. + """ + user_score = 0 + computer_score = 0 + + print("\n===== ROCK-PAPER-SCISSORS GAME =====") + print("First to 3 points wins!\n") + + while user_score < 3 and computer_score < 3: + print(f"\nScore: You {user_score} - {computer_score} Computer") + + user_choice = get_user_choice() + computer_choice = get_computer_choice() + + print(f"You chose: {user_choice}") + print(f"Computer chose: {computer_choice}") + + result = determine_winner(user_choice, computer_choice) + + if result == "user": + user_score += 1 + print("You win this round!") + elif result == "computer": + computer_score += 1 + print("Computer wins this round!") + else: + print("It's a tie!") + + print("\n===== GAME OVER =====") + if user_score > computer_score: + print(f"You win the game! Final score: You {user_score} - {computer_score} Computer") + else: + print(f"Computer wins the game! Final score: You {user_score} - {computer_score} Computer") + +if __name__ == "__main__": + try: + play_game() + except KeyboardInterrupt: + print("\nGame interrupted. Goodbye!") \ No newline at end of file From e06aaea9a05fb1a76d033afd3d48280bc7adff12 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 May 2025 00:59:19 +0000 Subject: [PATCH 3/3] Clean up code and .gitignore Co-authored-by: raffertyuy <1037626+raffertyuy@users.noreply.github.com> --- .gitignore | 5 ++- .../rock_paper_scissors.cpython-312.pyc | Bin 3535 -> 0 bytes personas/app-dev/games/rock_paper_scissors.py | 36 +++++++++--------- 3 files changed, 21 insertions(+), 20 deletions(-) delete mode 100644 personas/app-dev/games/__pycache__/rock_paper_scissors.cpython-312.pyc diff --git a/.gitignore b/.gitignore index a77b643..e6f3194 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ venv -sample-outputs \ No newline at end of file +sample-outputs +__pycache__/ +*.py[cod] +*$py.class \ No newline at end of file diff --git a/personas/app-dev/games/__pycache__/rock_paper_scissors.cpython-312.pyc b/personas/app-dev/games/__pycache__/rock_paper_scissors.cpython-312.pyc deleted file mode 100644 index 0ce613728d7d4c36e4e8021ae4a1c2d7750c8e8d..0000000000000000000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_ZSb$xgUH)go!s^e zZOrU=ep!ojJ&klX0s!P&gPw(D%(svS(66Ddz{8!?SvXrhiO$VdAFd#gzYjr0{#@aj zZ|gRBR|S2BM0bUQ+4H&UNKT{sveD{64z1OpT5C?5E^o#0a<{S3d==+0TC0aa_&PV6 zVZXvxc+t;-JPMWv^bkTT_LBvVER_3!H`L_in!I*w!ZzN3&6dc~dJ7#upotFmi5;Id zJ1->I+kj+;O&3^sGJa({SNp5E;+^_${WM*s;O^46r{oo-2xV(FtXVlKfcK;S*PPXp$(FCN>;mBio*@S&x#<^YKF5-1fbgjI;^0OUJ!%!AgQIi zrqYa|-fb2RAN6R4_G)qtD3{?;V}J})3@>W$SiMo}imgr`@IJ#ovd53^)0crg{wGiU zo$J5*W3u|;hOl!gweJnBhpJ1}_cuB=J~W0eZcP~B>wDhugV?}sY;Y~G-;>zwNv%Z= zfG<#;tX?w0@jdUGAZE1TFWxZlTSjGZ8-Li1{%XzrG!R{%+X?j6g0X7< z$1`g;_MyGE4?YPF)j}QX`cA077VN1C+rc;1rWq;mB$$LNzpjxTk7M>#;<3M*}F#g{U_cJz)GX-!q%HxeUH=s zJZ-#l%eW;N;rS=tEGvknH09 z>Q0X1zUN&W|2&Mi@F5@J=D5Q%9_|;1?XPh?ha+b=k*mMMAwIaK?>M{b4yP;mZ*TO| tK;4D-p8rBe2%b7b99;|<;o)z+2~g=uzEFdp{V$#~=uv3I`8RIF`9ID(qSXKZ diff --git a/personas/app-dev/games/rock_paper_scissors.py b/personas/app-dev/games/rock_paper_scissors.py index cf4b8a9..6dcca99 100755 --- a/personas/app-dev/games/rock_paper_scissors.py +++ b/personas/app-dev/games/rock_paper_scissors.py @@ -12,23 +12,22 @@ def get_user_choice(): """ Get the user's choice (rock, paper, or scissors). Validates input to ensure it's one of the valid options. - + Returns: str: The user's choice (rock, paper, or scissors) """ valid_choices = ["rock", "paper", "scissors"] - + while True: user_choice = input("Enter your choice (rock, paper, or scissors): ").lower().strip() if user_choice in valid_choices: return user_choice - else: - print(f"Invalid choice. Please enter one of: {', '.join(valid_choices)}") + print(f"Invalid choice. Please enter one of: {', '.join(valid_choices)}") def get_computer_choice(): """ Generate a random choice for the computer. - + Returns: str: The computer's choice (rock, paper, or scissors) """ @@ -37,27 +36,26 @@ def get_computer_choice(): def determine_winner(user_choice, computer_choice): """ Determine the winner of a round based on the choices. - + Args: user_choice (str): The user's choice computer_choice (str): The computer's choice - + Returns: str: 'user', 'computer', or 'tie' """ if user_choice == computer_choice: return "tie" - + winning_combinations = { "rock": "scissors", "paper": "rock", "scissors": "paper" } - + if winning_combinations[user_choice] == computer_choice: return "user" - else: - return "computer" + return "computer" def play_game(): """ @@ -65,21 +63,21 @@ def play_game(): """ user_score = 0 computer_score = 0 - + print("\n===== ROCK-PAPER-SCISSORS GAME =====") print("First to 3 points wins!\n") - + while user_score < 3 and computer_score < 3: print(f"\nScore: You {user_score} - {computer_score} Computer") - + user_choice = get_user_choice() computer_choice = get_computer_choice() - + print(f"You chose: {user_choice}") print(f"Computer chose: {computer_choice}") - + result = determine_winner(user_choice, computer_choice) - + if result == "user": user_score += 1 print("You win this round!") @@ -88,7 +86,7 @@ def play_game(): print("Computer wins this round!") else: print("It's a tie!") - + print("\n===== GAME OVER =====") if user_score > computer_score: print(f"You win the game! Final score: You {user_score} - {computer_score} Computer") @@ -99,4 +97,4 @@ def play_game(): try: play_game() except KeyboardInterrupt: - print("\nGame interrupted. Goodbye!") \ No newline at end of file + print("\nGame interrupted. Goodbye!")