awacke1's picture
Update app.py
e604411 verified
raw
history blame
1.68 kB
import streamlit as st
import numpy as np
import random
# Expanded set of emojis for landscape elements
emojis = ["🌳", "πŸƒ", "πŸ„", "🌲", "🌿", "🏠", "🏰", "πŸ—Ό", "πŸ›€οΈ", "🌊", "🏞️", "🌁", "🌾", "🏜️", "🏝️", "πŸ›–", "πŸ›€οΈ", "πŸ›£οΈ", "πŸ•οΈ", "πŸŒ‹", "⛰️", "🚢", "🧱", "🌡", "🍁", "🌼", "🌻", "🌺", "🏑", "πŸ—ΊοΈ"]
def initialize_emoji_map(size):
"""Initialize an emoji map with diverse landscape elements."""
return np.random.choice(emojis, (size, size))
def display_emoji_map(emoji_map):
"""Convert the emoji map to a string for display."""
map_str = "\n".join(["".join(row) for row in emoji_map])
st.text(map_str)
def move_emojis(emoji_map, direction):
"""Shift emojis in the specified direction with wrap-around."""
if direction == "North":
emoji_map = np.roll(emoji_map, 1, axis=0)
elif direction == "South":
emoji_map = np.roll(emoji_map, -1, axis=0)
elif direction == "West":
emoji_map = np.roll(emoji_map, 1, axis=1)
elif direction == "East":
emoji_map = np.roll(emoji_map, -1, axis=1)
return emoji_map
def main():
st.title("Emoji Landscape Exploration")
size = st.slider("Grid Size", 5, 40, 40)
if 'emoji_map' not in st.session_state:
st.session_state.emoji_map = initialize_emoji_map(size)
display_emoji_map(st.session_state.emoji_map)
direction = st.selectbox("Move direction", ["North", "South", "East", "West"])
if st.button("Move"):
st.session_state.emoji_map = move_emojis(st.session_state.emoji_map, direction)
st.experimental_rerun()
if __name__ == "__main__":
main()