Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import random
|
| 4 |
+
|
| 5 |
+
# Page Configuration
|
| 6 |
+
st.set_page_config(
|
| 7 |
+
page_title="๐ฎ Rock Paper Scissors",
|
| 8 |
+
page_icon="โ๏ธ",
|
| 9 |
+
layout="centered"
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
# Custom CSS for Funky Styling
|
| 13 |
+
st.markdown("""
|
| 14 |
+
<style>
|
| 15 |
+
.title {
|
| 16 |
+
text-align: center;
|
| 17 |
+
font-size: 3em;
|
| 18 |
+
font-weight: bold;
|
| 19 |
+
color: #FF6F61;
|
| 20 |
+
text-shadow: 2px 2px #FFE156;
|
| 21 |
+
}
|
| 22 |
+
.subtitle {
|
| 23 |
+
text-align: center;
|
| 24 |
+
font-size: 1.5em;
|
| 25 |
+
color: #4CAF50;
|
| 26 |
+
}
|
| 27 |
+
.choice {
|
| 28 |
+
font-size: 1.2em;
|
| 29 |
+
font-weight: bold;
|
| 30 |
+
color: #2196F3;
|
| 31 |
+
text-align: center;
|
| 32 |
+
}
|
| 33 |
+
.result {
|
| 34 |
+
text-align: center;
|
| 35 |
+
font-size: 1.5em;
|
| 36 |
+
font-weight: bold;
|
| 37 |
+
margin-top: 20px;
|
| 38 |
+
}
|
| 39 |
+
.win {
|
| 40 |
+
color: #4CAF50;
|
| 41 |
+
}
|
| 42 |
+
.lose {
|
| 43 |
+
color: #F44336;
|
| 44 |
+
}
|
| 45 |
+
.tie {
|
| 46 |
+
color: #FF9800;
|
| 47 |
+
}
|
| 48 |
+
.footer {
|
| 49 |
+
text-align: center;
|
| 50 |
+
margin-top: 50px;
|
| 51 |
+
font-size: 0.9em;
|
| 52 |
+
color: #777;
|
| 53 |
+
}
|
| 54 |
+
.play-button {
|
| 55 |
+
display: block;
|
| 56 |
+
margin: 20px auto;
|
| 57 |
+
padding: 10px 30px;
|
| 58 |
+
background: linear-gradient(135deg, #FF6F61, #FFE156);
|
| 59 |
+
border: none;
|
| 60 |
+
border-radius: 10px;
|
| 61 |
+
font-size: 1.2em;
|
| 62 |
+
font-weight: bold;
|
| 63 |
+
color: #fff;
|
| 64 |
+
cursor: pointer;
|
| 65 |
+
box-shadow: 2px 2px 5px #aaa;
|
| 66 |
+
}
|
| 67 |
+
</style>
|
| 68 |
+
""", unsafe_allow_html=True)
|
| 69 |
+
|
| 70 |
+
# Header
|
| 71 |
+
st.markdown("<h1 class='title'>๐ฎ Rock Paper Scissors</h1>", unsafe_allow_html=True)
|
| 72 |
+
st.markdown("<p class='subtitle'>Challenge the Computer and Win the Game!</p>", unsafe_allow_html=True)
|
| 73 |
+
|
| 74 |
+
# Choices
|
| 75 |
+
choices = ["๐ชจ Rock", "๐ Paper", "โ๏ธ Scissors"]
|
| 76 |
+
|
| 77 |
+
# User Input
|
| 78 |
+
user_choice = st.selectbox("๐ค Make Your Move:", choices)
|
| 79 |
+
play_button = st.button("๐ฅ Play Now")
|
| 80 |
+
|
| 81 |
+
# Game Logic
|
| 82 |
+
if play_button:
|
| 83 |
+
computer_choice = random.choice(choices)
|
| 84 |
+
|
| 85 |
+
# Determine Winner
|
| 86 |
+
if user_choice == computer_choice:
|
| 87 |
+
result = "๐ค It's a Tie!"
|
| 88 |
+
result_class = "tie"
|
| 89 |
+
elif (
|
| 90 |
+
(user_choice == "๐ชจ Rock" and computer_choice == "โ๏ธ Scissors") or
|
| 91 |
+
(user_choice == "๐ Paper" and computer_choice == "๐ชจ Rock") or
|
| 92 |
+
(user_choice == "โ๏ธ Scissors" and computer_choice == "๐ Paper")
|
| 93 |
+
):
|
| 94 |
+
result = "๐ You Win!"
|
| 95 |
+
result_class = "win"
|
| 96 |
+
else:
|
| 97 |
+
result = "๐ข You Lose!"
|
| 98 |
+
result_class = "lose"
|
| 99 |
+
|
| 100 |
+
# Display Results
|
| 101 |
+
st.markdown(f"<p class='choice'>๐ค <b>Your Choice:</b> {user_choice}</p>", unsafe_allow_html=True)
|
| 102 |
+
st.markdown(f"<p class='choice'>๐ค <b>Computer's Choice:</b> {computer_choice}</p>", unsafe_allow_html=True)
|
| 103 |
+
st.markdown(f"<p class='result {result_class}'>{result}</p>", unsafe_allow_html=True)
|
| 104 |
+
|
| 105 |
+
# Footer
|
| 106 |
+
st.markdown("<p class='footer'>๐ป <b>Developed by ChatGPT</b></p>", unsafe_allow_html=True)
|