Cs Project
Cs Project
Project Report on
ROCK PAPER SCISSORS
for
Computer Science
Session:2024-25
NAME: Neev Chaprana
ROLL NUMBER:
CLASS: XII-A
SUB. CODE: 083
CERTIFICATE
This is to certify that cadet Neev
Chaprana Roll no: ………………………
has successfully completed the
project work entitled ROCK PAPER
SCISSORS in the subject Computer
science (083) laid down in the
regulations of CBSE for the purposes
of Practical examination in Class XII to
be held in Eicher School, Faridabad,
Haryana
Mrs. Lalita
PGT Computer Science
Examiner
Name:
Signature:
TABLE OF CONTENT
S.no Description
1 ACKNOWLEDGEMENT
2 INTRODUCTION
3 OBJECTIVES OF THE
PROJECT
4 SYSTEM DEVELOPMENT
LIFE CYCLE(SDLO)
5 MODULES USED AND
THEIR PURPOSE
6 FLOW CHART
7 SOURCE CODE
8 OUTPUT
9 TESTING
10 HARDWARE AND
SOFTWARE
REQUIREMENT
11 INSTALLATION
PROCEDURE
12 BIBLIOGRAPHY
ACKNOWLEDGEMENT
Apart from my efforts, the success of any
project depends largely on the
encouragement and guidelines of many
others. I take this opportunity to express my
gratitude to the people who have been
instrumental in the successful completion of
this project.
I express my deep sense of gratitude to the
luminary The Principal who has been
continuously motivating and extending their
helping hand to us.
I express my sincere thanks to the
academician, the Vice Principal, for constant
encouragement and the guidance provided
during this project.
My sincere thanks to Mrs. Lalita,The guidance
and support received from all the members
who contributed and who are contributing to
this project, was vital for the success of the
project. I am grateful for their constant
support and help.
PROJECT ON
ROCK PAPER SCISSORS
INTRODUCTION
Rock, Paper, Scissors is a simple hand game
played between two participants, where rock
crushes scissors, scissors cuts paper, and
paper covers rock. Despite its simplicity, the
game offers insights into strategy, chance,
and decision-making. This project explores
the game’s dynamics, focusing on both
human vs. human and human vs. computer
interactions. We’ll examine how algorithms
can predict or improve decisions and discuss
how the game connects to concepts in
probability, game theory, and artificial
intelligence. Ultimately, this project highlights
Rock, Paper, Scissors as both entertaining and
educational tools.
HARDWARE AND
SOFTWARE
REQUIREMENTS
1. OPERATING SYSTEM: Windows 7 or Above
Mac OS X 10.11 or higher, 64-bit
Linux: RHEL 6/7, 64-bit
II. PROCESSOR: Intel(R) Core (TMi5-10400F
CPU @2.90GHz 2.90 GHz)
III. MOTHERBOARD: GIGABYTE B760M DS3H
AX DDR4 IV. RAM :8 GB+
V. HARD DISK: SATA 40 GB OR ABOVE
VI. CD/DVD r/w multi drive combo: (If back up
required)
VII. FLOPPY DRIVE: 1.44 MB (If Backup
required)
VIII. MONITOR :15-17 inch
PROJECT CODE
import random
import mysql.connector
from mysql.connector import Error
def connect_to_database():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="password",
database="rps_game" )
if connection.is_connected():
print("Connected to MySQL
database.")
return connection
except Error as e:
print(f"Error connecting to database:
{e}")
return None
def
insert_session_highest_winstreak(connection,
highest_winstreak):
try:
cursor = connection.cursor()
query = "INSERT INTO session_stats
(highest_winstreak) VALUES (%s)"
cursor.execute(query,
(highest_winstreak,))
connection.commit()
print(f"Session saved with highest win
streak: {highest_winstreak}")
except Error as e:
print(f"Error inserting data: {e}")
def get_user_choice():
print("Enter your choice: rock, paper, or
scissors")
while True:
choice = input("Your choice: ").lower()
if choice in ["rock", "paper", "scissors"]:
return choice
else:
print("Invalid choice. Please enter
rock, paper, or scissors.")
def get_computer_choice():
return random.choice(["rock", "paper",
"scissors"])
def determine_winner(user_choice,
computer_choice):
if user_choice == computer_choice:
return "tie"
elif (user_choice == "rock" and
computer_choice == "scissors") or \
(user_choice == "paper" and
computer_choice == "rock") or \
(user_choice == "scissors" and
computer_choice == "paper"):
return "user"
else:
return "computer"
def main():
connection = connect_to_database()
if not connection:
print("Unable to connect to the
database. Exiting game.")
return
while True:
user_choice = get_user_choice()
computer_choice =
get_computer_choice()
print(f"\nYou chose: {user_choice}")
print(f"Computer chose:
{computer_choice}")
result = determine_winner(user_choice,
computer_choice)
if result == "user":
win_streak += 1
highest_winstreak =
max(highest_winstreak, win_streak)
print(f"\nYou win! Current win streak:
{win_streak}")
elif result == "computer":
print("\nComputer wins! Your win
streak has ended.")
win_streak = 0
else:
print("\nIt's a tie! Your win streak
continues.")
play_again = input("Do you want to play
again? (yes/no): ").lower()
if play_again != "yes":
print(f"\nYour highest win streak this
session: {highest_winstreak}")
insert_session_highest_winstreak(connection,
highest_winstreak)
print("Thanks for playing! Goodbye!")
break
if connection.is_connected():
connection.close()
print("Database connection closed.")
if __name__ == "__main__":
main()
Screenshot of the game
Photo of MYSQL