File size: 3,478 Bytes
f2d0a0e
 
a0c5d9e
d078749
a0b9333
d078749
 
 
 
 
 
 
0d15259
d078749
 
 
 
a0b9333
0d15259
d078749
a0b9333
 
 
 
 
 
 
0d15259
d078749
a0b9333
d078749
 
a0b9333
d078749
a0b9333
 
 
 
 
 
 
 
d078749
 
0d15259
d078749
a0b9333
f2d0a0e
 
d078749
a0b9333
d078749
 
0d15259
d078749
 
0d15259
d078749
a0b9333
d078749
 
a0b9333
0d15259
d078749
 
a0b9333
d078749
 
 
 
 
 
a0b9333
d078749
 
 
f2d0a0e
 
d078749
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import streamlit as st
import numpy as np

# Helper functions for number theory-based emoji placement

def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

def fib_sequence(n):
    fib_seq = [0, 1]
    while fib_seq[-1] + fib_seq[-2] <= n:
        fib_seq.append(fib_seq[-1] + fib_seq[-2])
    return fib_seq[2:] # Exclude first two numbers for this use case

# Expanded set of emojis for landscape elements

nature_emojis = ["🌲", "🌳", "πŸƒ", "🌿", "πŸ„", "🌊", "🏞️", "🌁", "🌾", "🏜️", "🏝️", "πŸŒ‹", "⛰️", "🌡", "🍁", "🌼", "🌻", "🌺"]
building_emojis = ["🏠", "🏰", "πŸ—Ό", "πŸ›–", "πŸ•οΈ", "🧱", "🏑"]
infrastructure_emojis = ["πŸ›€οΈ", "πŸ›£οΈ", "πŸ—ΊοΈ"]
bird_emojis = ["🦜", "🦚", "πŸ¦‰", "πŸ¦†", "πŸ¦…", "🦩", "πŸ•ŠοΈ", "πŸ¦ƒ"]
animal_emojis = ["πŸ’", "🦍", "🐘", "🦏", "πŸ†", "πŸ…", "πŸƒ", "πŸ‚", "πŸ„", "πŸͺ", "🐫", "πŸ¦™", "🦘", "πŸ¦₯", "🐿️"]
fish_emojis = ["🐠", "🐟", "🐑", "🦈", "πŸ™", "🐚", "πŸ¦€", "🦞", "🦐", "🐬", "🐳", "πŸ‹"]

# Locations and emoji grid maps initialization

def initialize_locations(size):
    """Initialize different locations with unique emoji grids."""
    np.random.seed(42) # Optional: for reproducible emoji distributions
    locations = {
        'forest edge': np.random.choice(nature_emojis + bird_emojis + animal_emojis, (size, size)),
        'deep forest': np.random.choice(nature_emojis + bird_emojis + animal_emojis, (size, size)),
        'mountain range': np.random.choice(nature_emojis + animal_emojis, (size, size)),
        'coastal town': np.random.choice(building_emojis + infrastructure_emojis + fish_emojis, (size, size)),
        'desert oasis': np.random.choice(nature_emojis + animal_emojis, (size, size)),
        'urban cityscape': np.random.choice(building_emojis + infrastructure_emojis, (size, size)),
        'tropical island': np.random.choice(nature_emojis + bird_emojis + fish_emojis, (size, size)),
        'savanna plains': np.random.choice(nature_emojis + animal_emojis + bird_emojis, (size, size)),
    }
    return locations

# Directions for movement

directions = {"North": (-1, 0), "South": (1, 0), "West": (0, -1), "East": (0, 1)}

# Movement and emoji map update functions

def move_emojis(locations, current_location, direction):
    """Shift emojis in the specified direction with wrap-around for the current location."""
    dx, dy = directions[direction]
    locations[current_location] = np.roll(locations[current_location], shift=(dx, dy), axis=(0, 1))
    return locations

# Streamlit application setup

def main():
    st.title("Explore the Emoji World")
    size = st.sidebar.slider("Grid Size", 5, 50, 20)

    if 'locations' not in st.session_state:
        st.session_state.locations = initialize_locations(size)

    current_location = st.sidebar.selectbox("Select location", options=list(st.session_state.locations.keys()))
    emoji_map = st.session_state.locations[current_location]
    map_str = "\n".join(["".join(row) for row in emoji_map])
    st.text(map_str)

    direction = st.sidebar.selectbox("Move direction", ["None", "North", "South", "East", "West"])

    if direction != "None":
        st.session_state.locations = move_emojis(st.session_state.locations, current_location, direction)
        st.experimental_rerun()

if __name__ == "__main__":
    main()