awacke1 commited on
Commit
6f8bf13
Β·
verified Β·
1 Parent(s): 9353d37

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -118
app.py DELETED
@@ -1,118 +0,0 @@
1
- import streamlit as st
2
- import numpy as np
3
- import random
4
-
5
- # Streamlit caching for faster location initialization
6
- @st.cache(allow_output_mutation=True)
7
- def initialize_locations(size):
8
- """Initialize different locations with unique emoji grids."""
9
- np.random.seed(42) # Ensure reproducibility
10
-
11
- # Expanded emoji set for diverse landscapes
12
- emoji_set = ["🌲", "🌳", "πŸƒ", "πŸ„", "🏠", "🏰", "πŸ—Ό", "πŸ›€οΈ", "🌊", "🏞️",
13
- "🌁", "🌾", "🏜️", "🏝️", "πŸ›–", "πŸ›£οΈ", "πŸ•οΈ", "πŸŒ‹", "⛰️", "🧱",
14
- "🌡", "🍁", "🌼", "🌻", "🌺", "🏑", "πŸ—ΊοΈ", "πŸͺ¨", "πŸŒ…", "πŸŒ„",
15
- "🌠", "🌌", "🏞️", "πŸŒ‰", "πŸŒ‡", "πŸ”οΈ", "β›Ί", "🌲", "🌳", "πŸ‚"]
16
-
17
- # Randomize emoji placement for each location
18
- locations = {
19
- 'forest edge': np.random.choice(emoji_set, (size, size)),
20
- 'deep forest': np.random.choice(emoji_set, (size, size)),
21
- 'mountain range': np.random.choice(emoji_set, (size, size)),
22
- 'desert oasis': np.random.choice(emoji_set, (size, size)),
23
- 'city center': np.random.choice(emoji_set, (size, size)),
24
- 'starry night': np.random.choice(emoji_set, (size, size)),
25
- 'tropical island': np.random.choice(emoji_set, (size, size)),
26
- 'camping site': np.random.choice(emoji_set, (size, size)),
27
- }
28
- return locations
29
-
30
- def is_prime(n):
31
- if n <= 1:
32
- return False
33
- for i in range(2, int(np.sqrt(n)) + 1):
34
- if n % i == 0:
35
- return False
36
- return True
37
-
38
- def fib_sequence(n):
39
- fib_seq = [0, 1]
40
- while fib_seq[-1] + fib_seq[-2] <= n:
41
- fib_seq.append(fib_seq[-1] + fib_seq[-2])
42
- return fib_seq[2:] # Exclude first two numbers for this use case
43
-
44
- directions = {"North": (-1, 0), "South": (1, 0), "West": (0, -1), "East": (0, 1)}
45
-
46
- def move_emojis(locations, current_location, direction):
47
- dx, dy = directions[direction]
48
- locations[current_location] = np.roll(locations[current_location], shift=(dx, dy), axis=(0, 1))
49
- return locations
50
-
51
- def main():
52
- st.title("Explore the Emoji World")
53
-
54
- size = st.sidebar.slider("Grid Size", 5, 40, 20)
55
- delay = st.sidebar.slider("Update Delay (ms)", 0, 1000, 100)
56
-
57
- if 'locations' not in st.session_state:
58
- st.session_state.locations = initialize_locations(size)
59
-
60
- current_location = st.sidebar.selectbox("Select location", options=list(st.session_state.locations.keys()))
61
- emoji_map = st.session_state.locations[current_location]
62
-
63
- map_str = "\n".join(["".join(row) for row in emoji_map])
64
- st.text(map_str)
65
-
66
- # WASD-like controls using Streamlit buttons
67
- cols = st.columns(5)
68
- direction = None
69
-
70
- with cols[1]:
71
- if st.button('W'):
72
- direction = "North"
73
-
74
- with cols[0]:
75
- if st.button('A'):
76
- direction = "West"
77
-
78
- with cols[2]:
79
- if st.button('D'):
80
- direction = "East"
81
-
82
- with cols[4]:
83
- if st.button('S'):
84
- direction = "South"
85
-
86
- if direction:
87
- st.session_state.locations = move_emojis(st.session_state.locations, current_location, direction)
88
- st.experimental_rerun()
89
-
90
- st.sidebar.text("Controls: Use WASD buttons to navigate.")
91
- st.sidebar.text("Delay controls the speed of updates to help with motion sensitivity.")
92
-
93
- # Delay implementation
94
- st.time.sleep(delay / 1000.0) # Convert ms to seconds
95
-
96
- # Display additional information in the sidebar
97
- st.sidebar.header("Additional Information")
98
- st.sidebar.subheader("Prime Numbers")
99
- prime_num = st.sidebar.number_input("Enter a number to check if it's prime", min_value=1, step=1)
100
- if is_prime(prime_num):
101
- st.sidebar.write(f"{prime_num} is a prime number.")
102
- else:
103
- st.sidebar.write(f"{prime_num} is not a prime number.")
104
-
105
- st.sidebar.subheader("Fibonacci Sequence")
106
- fib_limit = st.sidebar.number_input("Enter a limit for the Fibonacci sequence", min_value=1, step=1)
107
- fib_sequence_list = fib_sequence(fib_limit)
108
- st.sidebar.write(f"Fibonacci sequence up to {fib_limit}: {', '.join(str(num) for num in fib_sequence_list)}")
109
-
110
- # Random emoji generator
111
- st.sidebar.subheader("Random Emoji Generator")
112
- num_emojis = st.sidebar.number_input("Number of random emojis", min_value=1, max_value=20, value=5, step=1)
113
- random_emojis = random.sample(emoji_set, num_emojis)
114
- st.sidebar.write("Random emojis:")
115
- st.sidebar.write(" ".join(random_emojis))
116
-
117
- if __name__ == "__main__":
118
- main()