File size: 1,684 Bytes
6654db0
 
e604411
6654db0
e604411
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6654db0
 
e604411
 
 
 
 
 
6654db0
e604411
 
6654db0
 
e604411
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
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()