import streamlit as st import random st.set_page_config(page_title="🎮 Mini Game Arcade", page_icon="🎲") st.title("🎮 Mini Game Arcade") # Game selection game = st.selectbox("Choose a game to play:", [ "Rock, Paper, Scissors", "Guess the Number", "Word Scramble", "Emoji Quiz", "Math Quiz", "Hangman", "Tic-Tac-Toe", "Coin Toss", "Dice Roll", "Memory Challenge" ]) # ------------------------------ if game == "Rock, Paper, Scissors": st.subheader("✊✋✌️ Rock, Paper, Scissors") user_choice = st.radio("Choose:", ["Rock", "Paper", "Scissors"]) if st.button("Play"): computer_choice = random.choice(["Rock", "Paper", "Scissors"]) st.write(f"Computer chose: **{computer_choice}**") if user_choice == computer_choice: st.info("It's a tie!") elif (user_choice, computer_choice) in [("Rock", "Scissors"), ("Scissors", "Paper"), ("Paper", "Rock")]: st.success("You win!") else: st.error("You lose!") # ------------------------------ elif game == "Guess the Number": st.subheader("🔢 Guess the Number (1-10)") secret = random.randint(1, 10) guess = st.number_input("Your guess:", 1, 10, step=1) if st.button("Check"): if guess == secret: st.success("🎉 Correct! You guessed it.") else: st.warning(f"Wrong! The number was {secret}.") # ------------------------------ elif game == "Word Scramble": st.subheader("🔤 Word Scramble") word = random.choice(["streamlit", "python", "arcade", "developer", "career"]) scrambled = "".join(random.sample(word, len(word))) answer = st.text_input(f"Unscramble this word: **{scrambled}**") if st.button("Check"): if answer.lower() == word: st.success("✅ Correct!") else: st.error(f"❌ Wrong! The word was: **{word}**") # ------------------------------ elif game == "Emoji Quiz": st.subheader("😊 Emoji Quiz") quiz = { "🦁👑": "lion king", "🍎📱": "apple", "🎬🍿": "movie", "⚽🏆": "football", } emoji, answer = random.choice(list(quiz.items())) user_answer = st.text_input(f"What does this mean? {emoji}") if st.button("Submit"): if user_answer.lower() == answer: st.success("Correct! 🎉") else: st.error(f"Nope! The answer was: {answer}") # ------------------------------ elif game == "Math Quiz": st.subheader("➕ Math Quiz") a, b = random.randint(1, 20), random.randint(1, 20) user_answer = st.number_input(f"What is {a} + {b}?", value=0) if st.button("Check Answer"): if user_answer == a+b: st.success("✅ Correct!") else: st.error(f"❌ Wrong! Answer is {a+b}.") # ------------------------------ elif game == "Hangman": st.subheader("🪢 Hangman (1 chance)") word = random.choice(["cat", "dog", "bat", "rat", "sun"]) display = "_ " * len(word) guess = st.text_input(f"Guess the word: {display}").lower() if st.button("Submit Guess"): if guess == word: st.success("🎉 You win!") else: st.error(f"You lose! Word was: {word}") # ------------------------------ elif game == "Tic-Tac-Toe": st.subheader("❌⭕ Tic-Tac-Toe") st.write("Sorry! Tic-Tac-Toe is currently just a placeholder (implementing full board interaction is advanced here).") st.info("You can extend this by adding a 3x3 grid with session state!") # ------------------------------ elif game == "Coin Toss": st.subheader("🪙 Coin Toss") if st.button("Toss Coin"): result = random.choice(["Heads", "Tails"]) st.write(f"Result: **{result}**") # ------------------------------ elif game == "Dice Roll": st.subheader("🎲 Dice Roll") if st.button("Roll Dice"): roll = random.randint(1,6) st.write(f"You rolled: **{roll}**") # ------------------------------ elif game == "Memory Challenge": st.subheader("🧠 Memory Challenge") numbers = [random.randint(1, 9) for _ in range(3)] st.write(f"Remember this sequence: {numbers}") guess = st.text_input("Enter the sequence (comma-separated):") if st.button("Check Sequence"): if guess.replace(" ", "") == ",".join(map(str, numbers)): st.success("🎉 Correct!") else: st.error(f"Wrong! It was: {numbers}")