rock_game / app.py
bhagwandas's picture
Update app.py
58aa986 verified
# app.py
import streamlit as st
import random
# Page Configuration
st.set_page_config(
page_title="๐ŸŽฎ Rock Paper Scissors",
page_icon="โœŒ๏ธ",
layout="centered"
)
# Custom CSS for Funky Styling
st.markdown("""
<style>
.title {
text-align: center;
font-size: 3em;
font-weight: bold;
color: #FF6F61;
text-shadow: 2px 2px #FFE156;
}
.subtitle {
text-align: center;
font-size: 1.5em;
color: #4CAF50;
}
.choice {
font-size: 1.2em;
font-weight: bold;
color: #2196F3;
text-align: center;
}
.result {
text-align: center;
font-size: 1.5em;
font-weight: bold;
margin-top: 20px;
}
.win {
color: #4CAF50;
}
.lose {
color: #F44336;
}
.tie {
color: #FF9800;
}
.footer {
text-align: center;
margin-top: 50px;
font-size: 0.9em;
color: #777;
}
.play-button {
display: block;
margin: 20px auto;
padding: 10px 30px;
background: linear-gradient(135deg, #FF6F61, #FFE156);
border: none;
border-radius: 10px;
font-size: 1.2em;
font-weight: bold;
color: #fff;
cursor: pointer;
box-shadow: 2px 2px 5px #aaa;
}
</style>
""", unsafe_allow_html=True)
# Header
st.markdown("<h1 class='title'>๐ŸŽฎ Rock Paper Scissors</h1>", unsafe_allow_html=True)
st.markdown("<p class='subtitle'>Challenge the Computer and Win the Game!</p>", unsafe_allow_html=True)
# Choices
choices = ["๐Ÿชจ Rock", "๐Ÿ“„ Paper", "โœ‚๏ธ Scissors"]
# User Input
user_choice = st.selectbox("๐Ÿค” Make Your Move:", choices)
play_button = st.button("๐Ÿ”ฅ Play Now")
# Game Logic
if play_button:
computer_choice = random.choice(choices)
# Determine Winner
if user_choice == computer_choice:
result = "๐Ÿค It's a Tie!"
result_class = "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")
):
result = "๐ŸŽ‰ You Win!"
result_class = "win"
else:
result = "๐Ÿ˜ข You Lose!"
result_class = "lose"
# Display Results
st.markdown(f"<p class='choice'>๐Ÿ‘ค <b>Your Choice:</b> {user_choice}</p>", unsafe_allow_html=True)
st.markdown(f"<p class='choice'>๐Ÿค– <b>Computer's Choice:</b> {computer_choice}</p>", unsafe_allow_html=True)
st.markdown(f"<p class='result {result_class}'>{result}</p>", unsafe_allow_html=True)
# Footer
st.markdown("<p class='footer'>๐Ÿ’ป <b>Developed by ChatGPT</b></p>", unsafe_allow_html=True)