File size: 1,631 Bytes
f62874c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import streamlit as st
import random

# Page config (wide layout + nicer title)
st.set_page_config(page_title="๐ŸŽฎ Rock Paper Scissors", layout="wide")

# Custom CSS for buttons
st.markdown("""
<style>
    .btn-img {
        background:none;
        border:none;
        padding: 10px;
        cursor: pointer;
    }
    .btn-img:hover {
        transform: scale(1.2);
        transition-duration: 0.2s;
    }
</style>
""", unsafe_allow_html=True)

st.title("๐Ÿชจ๐Ÿ“„โœ‚๏ธ Rock Paper Scissors")

# Show choices as images (you can replace URLs with your own hosted images)
col1, col2, col3 = st.columns(3)

with col1:
    if st.button("๐Ÿชจ Rock", key="rock"):
        user_choice = "Rock"
with col2:
    if st.button("๐Ÿ“„ Paper", key="paper"):
        user_choice = "Paper"
with col3:
    if st.button("โœ‚๏ธ Scissors", key="scissors"):
        user_choice = "Scissors"

try:
    user_choice
except NameError:
    st.write("๐Ÿ‘‰ **Choose Rock, Paper, or Scissors to start!**")
else:
    # Computer move
    computer_choice = random.choice(["Rock", "Paper", "Scissors"])

    # Display choices
    st.markdown(f"๐Ÿ’ก **You chose:** {user_choice}")
    st.markdown(f"๐Ÿค– **Computer chose:** {computer_choice}")

    # Result logic
    if user_choice == computer_choice:
        st.info("๐Ÿค It's a 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")
    ):
        st.balloons()
        st.success("๐ŸŽ‰ You win!")
    else:
        st.error("๐Ÿ˜ข You lose!")