From 217c17a5b8a7470d0456affb159b2b02b810dbe3 Mon Sep 17 00:00:00 2001 From: AaronTchoffo Date: Mon, 30 Mar 2026 20:38:24 +0100 Subject: [PATCH 1/3] Create rock-paper-scissors folder and main.py - Added folder for Rock Paper Scissors mini projects. - Added initial main.py script --- rock-paper-scissors/main.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 rock-paper-scissors/main.py diff --git a/rock-paper-scissors/main.py b/rock-paper-scissors/main.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/rock-paper-scissors/main.py @@ -0,0 +1 @@ + From df3351c6d3f0e2c239435ab5ae8c16bcb5650c8f Mon Sep 17 00:00:00 2001 From: AaronTchoffo Date: Mon, 30 Mar 2026 22:13:38 +0100 Subject: [PATCH 2/3] Implement Rock Paper Scissors game with GUI - Full graphical interface using Tkinter - Buttons for Rock, Paper, Scissors - Displays computer choice, result, and score - Original game logic preserved --- rock-paper-scissors/main.py | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/rock-paper-scissors/main.py b/rock-paper-scissors/main.py index 8b137891..82452559 100644 --- a/rock-paper-scissors/main.py +++ b/rock-paper-scissors/main.py @@ -1 +1,82 @@ +"""Rock Paper Scissors Game with GUI""" +import random +import tkinter as tk +from tkinter import messagebox +# Global variables +computer_score = 0 +player_score = 0 +options = ["Scissors", "Rock", "Paper"] + +def victory_of_x(X, Y): + """Determine if X wins against Y""" + if X == "Scissors" and Y == "Paper": + return True + elif X == "Paper" and Y == "Rock": + return True + elif X == "Rock" and Y == "Scissors": + return True + else: + return False + +def play(player_choice): + """Handle a round of the game""" + global player_score, computer_score + computer_choice = random.choice(options) + if player_choice == computer_choice: + result_text.set(f"Both chose {player_choice}. It's a tie!") + else: + if victory_of_x(player_choice, computer_choice): + player_score += 1 + result_text.set(f"Player chose {player_choice}, computer chose {computer_choice}.\nPlayer wins this round!") + else: + computer_score += 1 + result_text.set(f"Player chose {player_choice}, computer chose {computer_choice}.\nComputer wins this round!") + + score_text.set(f"Score -> Player: {player_score}, Computer: {computer_score}") + + +def reset_game(): + """Reset scores and start a new game""" + global player_score, computer_score + player_score = 0 + computer_score = 0 + result_text.set("New game started! Make your choice.") + score_text.set("Score -> Player: 0, Computer: 0") + + +# Create main window +root = tk.Tk() +root.title("Rock Paper Scissors") +root.geometry("450x300") +root.resizable(False, False) + +# Result and Score Labels +result_text = tk.StringVar() +result_text.set("Welcome to Rock Paper Scissors! Make your choice.") +result_label = tk.Label(root, textvariable=result_text, wraplength=400, justify="center", font=("Arial", 12)) +result_label.pack(pady=20) + +score_text = tk.StringVar() +score_text.set("Score -> Player: 0, Computer: 0") +score_label = tk.Label(root, textvariable=score_text, font=("Arial", 12)) +score_label.pack(pady=10) + +# Buttons for player choices +button_frame = tk.Frame(root) +button_frame.pack(pady=20) + +scissors_button = tk.Button(button_frame, text="Scissors", width=12, command=lambda: play("Scissors")) +scissors_button.grid(row=0, column=0, padx=5) + +rock_button = tk.Button(button_frame, text="Rock", width=12, command=lambda: play("Rock")) +rock_button.grid(row=0, column=1, padx=5) + +paper_button = tk.Button(button_frame, text="Paper", width=12, command=lambda: play("Paper")) +paper_button.grid(row=0, column=2, padx=5) + +# Reset Game Button +reset_button = tk.Button(root, text="New Game", command=reset_game) +reset_button.pack(pady=10) + +root.mainloop() From 119cbd42ee3f611349b1f31e5f1e45365c7e8bd4 Mon Sep 17 00:00:00 2001 From: AaronTchoffo Date: Mon, 30 Mar 2026 22:25:25 +0100 Subject: [PATCH 3/3] Create README for Rock Paper Scissors game Added a README file with game description, rules, features, and instructions. --- rock-paper-scissors/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 rock-paper-scissors/README.md diff --git a/rock-paper-scissors/README.md b/rock-paper-scissors/README.md new file mode 100644 index 00000000..ff5efd54 --- /dev/null +++ b/rock-paper-scissors/README.md @@ -0,0 +1,30 @@ +# Rock Paper Scissors GUI 🎮 + +A fun **Rock Paper Scissors** game with a graphical interface built using **Tkinter**. +Play against the computer, keep track of your score, and see who is the ultimate champion! + +## Game Rules 📝 + +- The game is between a **player** and the **computer**. +- You can choose one of three options: **Rock**, **Paper**, or **Scissors**. +- The rules are simple: + - Rock beats Scissors + - Scissors beats Paper + - Paper beats Rock +- If both the player and the computer choose the same option, it’s a **tie**. +- The score is updated after each round, and you can choose to play a new game or stop. + +## Features ✨ + +- Graphical interface with Tkinter +- Real-time score tracking +- Input validation for smooth gameplay +- Easy to run and play + +## How to Run ▶️ + +1. Make sure you have **Python 3** installed. +2. Run the game: + +```bash +python main.py